square-spoon-72769
11/21/2025, 2:48 PMconsole but not on dev or start and the calling or from the playground. Is there some quick fix even if hacky? This is really blocking me to enjoy the features in the new version, cc @refined-appointment-81829 @lively-winter-88668square-spoon-72769
11/21/2025, 2:51 PMdef load_audio(text: str) -> tuple[bytes, int, int, int] | None:
if text not in TEXT_TO_AUDIO:
return None
audio_path = TEXT_TO_AUDIO[text]
if audio_path.exists() is False:
logger.error(f"Audio file `{audio_path}` does not exist. Falling back to TTS.")
return None
# Load audio using soundfile
audio_data, sample_rate = sf.read(str(audio_path), dtype="int16")
num_channels = 1
samples_per_channel = len(audio_data)
# Convert to bytes
frames = audio_data.tobytes()
return frames, sample_rate, num_channels, samples_per_channel
def build_audio_generator(audio_data: tuple[bytes, int, int, int]):
"""
Build an async generator that yields a single audio frame from the given audio data.
Args:
audio_data: Tuple of (frames, sample_rate, num_channels, samples_per_channel)
Returns:
An async generator that yields a single AudioFrame
"""
frames, sample_rate, num_channels, samples_per_channel = audio_data
audio_frame = rtc.AudioFrame(
data=frames,
sample_rate=sample_rate,
num_channels=num_channels,
samples_per_channel=samples_per_channel,
)
async def audio_generator():
yield audio_frame
return audio_generator
and then
audio_data = load_audio(text)
return await self.session.say(
audio=build_audio_generator(audio_data)(),
text=text,
allow_interruptions=allow_interruptions,
)square-spoon-72769
11/21/2025, 2:52 PMlively-winter-88668
11/21/2025, 3:29 PMsquare-spoon-72769
11/21/2025, 3:39 PMsquare-spoon-72769
11/21/2025, 3:40 PMlively-winter-88668
11/21/2025, 3:49 PMsquare-spoon-72769
11/21/2025, 3:49 PMsquare-spoon-72769
11/21/2025, 3:51 PMsquare-spoon-72769
11/21/2025, 4:45 PMsquare-spoon-72769
11/21/2025, 4:57 PMabundant-activity-82320
11/21/2025, 5:13 PMsquare-spoon-72769
11/21/2025, 5:51 PMsquare-spoon-72769
11/24/2025, 9:45 AMlively-winter-88668
11/24/2025, 11:13 AMsquare-spoon-72769
11/25/2025, 6:55 PMsquare-spoon-72769
11/25/2025, 7:12 PMrefined-appointment-81829
11/25/2025, 7:39 PMsquare-spoon-72769
11/25/2025, 7:58 PMrefined-appointment-81829
11/25/2025, 8:02 PMsquare-spoon-72769
11/25/2025, 8:03 PMsquare-spoon-72769
11/25/2025, 8:04 PMrefined-appointment-81829
11/25/2025, 8:06 PMsquare-spoon-72769
11/25/2025, 8:06 PMsquare-spoon-72769
11/25/2025, 8:15 PMasync def tts_node(
self, text: AsyncIterable[str], model_settings: ModelSettings
) -> AsyncIterable[rtc.AudioFrame]:
processed_text = self.process_text(text, show_in_log=True)
return super().tts_node(processed_text, model_settings) # type: ignore
does this intervene when session.say(audio=...) ?refined-appointment-81829
11/25/2025, 8:52 PMsquare-spoon-72769
11/25/2025, 9:32 PMasync def say_audio(self, text: str, allow_interruptions: bool = True):
"""
Try to play scripted audio for the given text, fall back to TTS if not available.
"""
audio_path = load_audio(text)
if audio_path is None:
return await self.session.say(
text,
allow_interruptions=allow_interruptions,
)
<http://logger.info|logger.info>(f"Playing scripted audio for text: {text}")
return await self.session.say(
audio=audio_frames_from_file(str(audio_path)),
text=text,
allow_interruptions=allow_interruptions,
)refined-appointment-81829
11/25/2025, 9:41 PMload_audio?square-spoon-72769
11/25/2025, 11:37 PMaudio_frames_from_file. I saw it somewhere and then updated load_audio so just get the pathlively-winter-88668
11/26/2025, 9:18 AMsquare-spoon-72769
11/26/2025, 10:24 AMlively-winter-88668
11/26/2025, 10:27 AM