Commit ·
0e8e69f
1
Parent(s): c8d1d7c
Update main.py
Browse files
main.py
CHANGED
|
@@ -45,10 +45,13 @@ tts = TTS(m, gpu=True)
|
|
| 45 |
tts.to("cuda")
|
| 46 |
|
| 47 |
@app.get("/text-to-speech/")
|
| 48 |
-
def text_to_speech(text
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
return FileResponse(audio_file, media_type='audio/mpeg')
|
| 54 |
|
|
|
|
| 45 |
tts.to("cuda")
|
| 46 |
|
| 47 |
@app.get("/text-to-speech/")
|
| 48 |
+
def text_to_speech(text,language):
|
| 49 |
+
if language=="vietnamese":
|
| 50 |
+
from gtts import gTTS
|
| 51 |
+
tts = gTTS(text)
|
| 52 |
+
audio_file = 'text_to_speech.mp3'
|
| 53 |
+
tts.save(audio_file)
|
| 54 |
+
else:
|
| 55 |
+
tts.tts_to_file(text,speaker_wav="input.wav", file_path='text_to_speech.mp3')
|
| 56 |
return FileResponse(audio_file, media_type='audio/mpeg')
|
| 57 |
|