Arafath10 commited on
Commit
df2db28
·
verified ·
1 Parent(s): 35f9a40

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +22 -0
main.py CHANGED
@@ -47,6 +47,28 @@ async def generate_audio(
47
  speaker_wav=FIXED_SPEAKER_WAV,
48
  language=language
49
  )
 
50
  yield f"out_{idx}.wav"
51
 
52
  return StreamingResponse(audio_stream(), media_type="audio/wav")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  speaker_wav=FIXED_SPEAKER_WAV,
48
  language=language
49
  )
50
+ print(file_path)
51
  yield f"out_{idx}.wav"
52
 
53
  return StreamingResponse(audio_stream(), media_type="audio/wav")
54
+
55
+ @app.post("/generate-audio_normal/")
56
+ async def generate-audio_normal(
57
+ text: str = Query(..., description="The input text to convert to speech."),
58
+ language: str = Query("en", description="Language code for TTS (e.g., 'en' for English).")
59
+ ):
60
+
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,
67
+ file_path=f"out_{idx}.wav",
68
+ speaker_wav=FIXED_SPEAKER_WAV,
69
+ language=language
70
+ )
71
+ print(file_path)
72
+ return f"out_{idx}.wav"
73
+
74
+ #return StreamingResponse(audio_stream(), media_type="audio/wav")