Chandranshu Jain
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import os
|
|
3 |
import gradio as gr
|
4 |
import torch
|
5 |
from IPython.display import Audio as IPythonAudio
|
|
|
|
|
6 |
|
7 |
#Audio to text
|
8 |
asr = pipeline(task="automatic-speech-recognition",
|
@@ -24,9 +26,10 @@ def transcribe_speech(filepath):
|
|
24 |
src_lang="eng_Latn",
|
25 |
tgt_lang="hin_Deva")
|
26 |
narrated_text=pipe(output[0]['translation_text'])
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
|
31 |
mic_transcribe = gr.Interface(
|
32 |
fn=transcribe_speech,
|
|
|
3 |
import gradio as gr
|
4 |
import torch
|
5 |
from IPython.display import Audio as IPythonAudio
|
6 |
+
from gtts import gTTS
|
7 |
+
import IPython.display as ipd
|
8 |
|
9 |
#Audio to text
|
10 |
asr = pipeline(task="automatic-speech-recognition",
|
|
|
26 |
src_lang="eng_Latn",
|
27 |
tgt_lang="hin_Deva")
|
28 |
narrated_text=pipe(output[0]['translation_text'])
|
29 |
+
tts = gTTS(text=narrated_text, lang='hi', slow=False)
|
30 |
+
tts.save("translated_audio.mp3")
|
31 |
+
|
32 |
+
return ipd.Audio("translated_audio.mp3", autoplay=True)
|
33 |
|
34 |
mic_transcribe = gr.Interface(
|
35 |
fn=transcribe_speech,
|