Update inference.py
Browse files- inference.py +29 -7
inference.py
CHANGED
|
@@ -1,12 +1,34 @@
|
|
| 1 |
from TTS.api import TTS
|
| 2 |
|
| 3 |
-
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
from IPython.display import Audio
|
| 12 |
-
Audio("baseline.wav")
|
|
|
|
| 1 |
from TTS.api import TTS
|
| 2 |
|
| 3 |
+
model_name = TTS("bangla-speech-processing/bangla_tts_female") # local model path or Hugging Face ID
|
| 4 |
|
| 5 |
+
tts = TTS(model_name=model_name, progress_bar=False, gpu=False)
|
| 6 |
|
| 7 |
+
|
| 8 |
+
def text_to_speech(text):
|
| 9 |
+
output_path = "output.wav"
|
| 10 |
+
tts.tts_to_file(text=text, file_path=output_path)
|
| 11 |
+
return output_path
|
| 12 |
+
|
| 13 |
+
# Gradio app
|
| 14 |
+
demo = gr.Interface(
|
| 15 |
+
fn=text_to_speech,
|
| 16 |
+
inputs="text",
|
| 17 |
+
outputs="audio",
|
| 18 |
+
title="Bangla Text to Speech",
|
| 19 |
+
description="Enter Bangla text and get speech output"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
demo.launch()
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# tts --model_path bangla_tts_female/pytorch_model.pth \
|
| 29 |
+
# --config_path bangla_tts_female/config.json \
|
| 30 |
+
# --text "আমি বাংলাদেশ থেকে এসেছি।" \
|
| 31 |
+
# --out_path baseline.wav
|
| 32 |
|
| 33 |
+
# from IPython.display import Audio
|
| 34 |
+
# Audio("baseline.wav")
|