Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import torch
|
2 |
import os
|
3 |
-
from transformers import pipeline, VitsModel, VitsTokenizer
|
4 |
import numpy as np
|
5 |
os.system("pip install git+https://github.com/openai/whisper.git")
|
6 |
import gradio as gr
|
@@ -43,7 +43,7 @@ tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-eng")
|
|
43 |
def translate(audio):
|
44 |
# return inference(audio)
|
45 |
outputs = pipe(audio, max_new_tokens=256,
|
46 |
-
generate_kwargs={"task": "translate"
|
47 |
return outputs["text"]
|
48 |
|
49 |
|
@@ -70,7 +70,7 @@ def predict(transType, language, audio, audio_mic = None):
|
|
70 |
print("debug1:", audio,"debug2", audio_mic)
|
71 |
if not audio and audio_mic:
|
72 |
audio = audio_mic
|
73 |
-
|
74 |
if transType == "Text":
|
75 |
return translate(audio), None
|
76 |
if transType == "Audio":
|
@@ -95,8 +95,8 @@ demo = gr.Interface(
|
|
95 |
inputs=[
|
96 |
gr.Radio(label="Choose your output format", choices=transTypes),
|
97 |
gr.Radio(label="Choose a source language", choices=supportLangs, value="Swedish"),
|
98 |
-
|
99 |
-
gr.Audio(label="Import an audio", sources="upload", type="numpy"),
|
100 |
gr.Audio(label="Record an audio", sources="microphone", type="filepath"),
|
101 |
],
|
102 |
outputs=[
|
|
|
1 |
import torch
|
2 |
import os
|
3 |
+
from transformers import pipeline, VitsModel, VitsTokenizer, SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor
|
4 |
import numpy as np
|
5 |
os.system("pip install git+https://github.com/openai/whisper.git")
|
6 |
import gradio as gr
|
|
|
43 |
def translate(audio):
|
44 |
# return inference(audio)
|
45 |
outputs = pipe(audio, max_new_tokens=256,
|
46 |
+
generate_kwargs={"task": "translate"})
|
47 |
return outputs["text"]
|
48 |
|
49 |
|
|
|
70 |
print("debug1:", audio,"debug2", audio_mic)
|
71 |
if not audio and audio_mic:
|
72 |
audio = audio_mic
|
73 |
+
|
74 |
if transType == "Text":
|
75 |
return translate(audio), None
|
76 |
if transType == "Audio":
|
|
|
95 |
inputs=[
|
96 |
gr.Radio(label="Choose your output format", choices=transTypes),
|
97 |
gr.Radio(label="Choose a source language", choices=supportLangs, value="Swedish"),
|
98 |
+
gr.Audio(label="Import an audio", sources="upload", type="filepath"),
|
99 |
+
#gr.Audio(label="Import an audio", sources="upload", type="numpy"),
|
100 |
gr.Audio(label="Record an audio", sources="microphone", type="filepath"),
|
101 |
],
|
102 |
outputs=[
|