Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -40,6 +40,7 @@ async def generate_audio(
|
|
| 40 |
text_chunks = split_text(text, 20)
|
| 41 |
|
| 42 |
for idx, chunk in enumerate(text_chunks):
|
|
|
|
| 43 |
# Generate audio for each chunk and yield as bytes
|
| 44 |
tts.tts_to_file(
|
| 45 |
text=chunk,
|
|
@@ -47,8 +48,11 @@ async def generate_audio(
|
|
| 47 |
speaker_wav=FIXED_SPEAKER_WAV,
|
| 48 |
language=language
|
| 49 |
)
|
| 50 |
-
print(
|
| 51 |
-
yield
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
return StreamingResponse(audio_stream(), media_type="audio/wav")
|
| 54 |
|
|
@@ -61,6 +65,7 @@ async def generate_audio_normal(
|
|
| 61 |
text_chunks = split_text(text, 20)
|
| 62 |
|
| 63 |
for idx, chunk in enumerate(text_chunks):
|
|
|
|
| 64 |
# Generate audio for each chunk and yield as bytes
|
| 65 |
tts.tts_to_file(
|
| 66 |
text=chunk,
|
|
@@ -68,7 +73,7 @@ async def generate_audio_normal(
|
|
| 68 |
speaker_wav=FIXED_SPEAKER_WAV,
|
| 69 |
language=language
|
| 70 |
)
|
| 71 |
-
print(
|
| 72 |
return f"out_{idx}.wav"
|
| 73 |
|
| 74 |
#return StreamingResponse(audio_stream(), media_type="audio/wav")
|
|
|
|
| 40 |
text_chunks = split_text(text, 20)
|
| 41 |
|
| 42 |
for idx, chunk in enumerate(text_chunks):
|
| 43 |
+
print(chunk)
|
| 44 |
# Generate audio for each chunk and yield as bytes
|
| 45 |
tts.tts_to_file(
|
| 46 |
text=chunk,
|
|
|
|
| 48 |
speaker_wav=FIXED_SPEAKER_WAV,
|
| 49 |
language=language
|
| 50 |
)
|
| 51 |
+
print(f"out_{idx}.wav")
|
| 52 |
+
# Read the file content and yield as binary
|
| 53 |
+
with open(f"out_{idx}.wav", "rb") as audio_file:
|
| 54 |
+
yield audio_file.read()
|
| 55 |
+
|
| 56 |
|
| 57 |
return StreamingResponse(audio_stream(), media_type="audio/wav")
|
| 58 |
|
|
|
|
| 65 |
text_chunks = split_text(text, 20)
|
| 66 |
|
| 67 |
for idx, chunk in enumerate(text_chunks):
|
| 68 |
+
print(chunk)
|
| 69 |
# Generate audio for each chunk and yield as bytes
|
| 70 |
tts.tts_to_file(
|
| 71 |
text=chunk,
|
|
|
|
| 73 |
speaker_wav=FIXED_SPEAKER_WAV,
|
| 74 |
language=language
|
| 75 |
)
|
| 76 |
+
print(f"out_{idx}.wav")
|
| 77 |
return f"out_{idx}.wav"
|
| 78 |
|
| 79 |
#return StreamingResponse(audio_stream(), media_type="audio/wav")
|