Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fafcc1

Browse files
BortlesboatYaoyaoChang
authored andcommitted
fix: handle missing speech output in realtime demo
When outputs.speech_outputs is empty or None, the code falls through to lines that reference audio_duration and rtf (never assigned in the else branch), causing NameError. It also tries to index outputs.speech_outputs[0] for save_audio, which would raise IndexError. Early return when no audio is generated.
1 parent 939f1cb commit 9fafcc1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

demo/realtime_model_inference_from_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ def main():
266266
print(f"RTF (Real Time Factor): {rtf:.2f}x")
267267
else:
268268
print("No audio output generated")
269-
269+
return
270+
270271
# Calculate token metrics
271272
input_tokens = inputs['tts_text_ids'].shape[1] # Number of input tokens
272273
output_tokens = outputs.sequences.shape[1] # Total tokens (input + generated)

0 commit comments

Comments
 (0)