Hello team :wave: We use `self.session.say(text, a...
# agents
p
Hello team 👋 We use
self.session.say(text, audio)
to play pre-recorded segments quite a lot. I have just come across an instance where one of the segments has an audio effect that simulates breathing in, and for some reason that bit sounds completely off when playing through Livekit, but when played as an mp3 file on my laptop it sounds just right. Any chance there is anything going on behind the scenes of the
.say
method that is filtering noises not recognized as words?
We do something like this:
Copy code
await self.session.say(text=text, audio=self.get_audio(file_name))

# ...

async def get_audio(file_name: str) -> AsyncGenerator[rtc.AudioFrame, None]:
    async for audio_frame in audio_frames_from_file(file_path=file_name):
        yield audio_frame
This is how one of my files sound
Has anyone seen anything like this? 🙏
l
Did you try with https://github.com/livekit-examples/python-agents-examples/blob/main/basics/playing_audio.py ? There shouldn't be any filtering when calling
session.say()
with audio.
p
I just did, same issue 😕
l
The issue happens with both the .wav in that sample AND your test.wav? Or only with your test.wav?
p
No, the issue it's only present on my
test.wav
, when the breathing sound happens. The words on my file sound just fine too, it's when we get to the breathing sounds that they get distorted for some reason 🤔
I have tried resampling my file too without luck
l
I see what you mean! That's strange isn't it. I tried modifying the amplification as a test, and the amplified wave didn't show the distortion. I'm not sure what is going on, as I didn't think that API was subject to filtering. I remembered the engineering team added some new audio files recently to the repo, but unfortunately none of them were breathing: https://github.com/livekit/agents/pull/4165/files. The easiest thing to do at this stage might be to generate a different waveform, with amplified breathing - the attached sounds better to my ears (ignore that it is converted to ogg, that was just be testing if that helped, which it didn't)
p
Thank you for spending the time there! 🙏 Yeah, that might be my only solution for the time being
s
I also had issues with playing audios after upgrading to 1.3+, and the solution was
record=False
(but maybe that's not needed anymore), see thread https://livekit-users.slack.com/archives/C07FY8WHGPM/p1764152826666859?thread_ts=1763736513.880999&cid=C07FY8WHGPM
p
Thanks! I also faced that issue with agent observability enabled, however this seems to be a different one
👍 1