Update app.py
Browse files
app.py
CHANGED
|
@@ -141,6 +141,12 @@ LANGUAGES = {
|
|
| 141 |
'zulu' : 'zu',
|
| 142 |
}
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
def translate(message, lang):
|
| 145 |
res = GoogleTranslator(source='sv', target=lang).translate(message)
|
| 146 |
if res != None and res != "":
|
|
@@ -159,9 +165,13 @@ def transcribe(audio, lang, history):
|
|
| 159 |
with gr.Blocks() as demo:
|
| 160 |
history = gr.State([])
|
| 161 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
| 162 |
with gr.Column():
|
| 163 |
language = gr.Dropdown(list(LANGUAGES.keys()))
|
| 164 |
-
audio =
|
|
|
|
| 165 |
submit = gr.Button(value="Translate")
|
| 166 |
with gr.Column():
|
| 167 |
chatbot = gr.Chatbot().style(color_map=("green", "gray"))
|
|
|
|
| 141 |
'zulu' : 'zu',
|
| 142 |
}
|
| 143 |
|
| 144 |
+
def get_soundfile(link):
|
| 145 |
+
yt = YouTube(link)
|
| 146 |
+
audio = yt.streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
|
| 147 |
+
|
| 148 |
+
return audio
|
| 149 |
+
|
| 150 |
def translate(message, lang):
|
| 151 |
res = GoogleTranslator(source='sv', target=lang).translate(message)
|
| 152 |
if res != None and res != "":
|
|
|
|
| 165 |
with gr.Blocks() as demo:
|
| 166 |
history = gr.State([])
|
| 167 |
with gr.Row():
|
| 168 |
+
with gr.Column():
|
| 169 |
+
link = gr.Textbox(label = "Put YouTube link here")
|
| 170 |
+
audio = get_soundfile(link)
|
| 171 |
with gr.Column():
|
| 172 |
language = gr.Dropdown(list(LANGUAGES.keys()))
|
| 173 |
+
if audio == None:
|
| 174 |
+
audio = gr.Audio(source="microphone", type="filepath")
|
| 175 |
submit = gr.Button(value="Translate")
|
| 176 |
with gr.Column():
|
| 177 |
chatbot = gr.Chatbot().style(color_map=("green", "gray"))
|