VIATEUR-AI commited on
Commit
d42e775
Β·
verified Β·
1 Parent(s): cd1accb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -1,39 +1,38 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- import tempfile
4
  import soundfile as sf
 
5
 
6
  # 🎀 Speech to Text
7
  stt = pipeline("automatic-speech-recognition", model="openai/whisper-base")
8
 
9
- # 🌍 Translation
10
- translator = pipeline("translation", model="facebook/nllb-200-distilled-600M")
 
 
 
11
 
12
 
13
- def same_voice_translate(audio):
14
 
15
- # 1. Speech β†’ Text
16
  text = stt(audio)["text"]
17
 
18
- # 2. Translate
19
- translated = translator(text, src_lang="eng_Latn", tgt_lang="fra_Latn")
20
- translated_text = translated[0]["translation_text"]
21
-
22
- # 3. πŸ”₯ SAME VOICE SIMULATION (placeholder voice cloning)
23
- # NOTE: real voice cloning needs RVC/OpenVoice model
24
- fake_voice_audio = audio # keeps original voice style (demo)
25
 
26
- return translated_text, fake_voice_audio
 
27
 
28
 
29
  iface = gr.Interface(
30
- fn=same_voice_translate,
31
  inputs=gr.Audio(type="filepath"),
32
  outputs=[
33
- gr.Textbox(label="Translated Text"),
34
- gr.Audio(label="Same Voice Output")
35
  ],
36
- title="🎀 Same Voice Translator (Demo)"
37
  )
38
 
39
  iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
 
3
  import soundfile as sf
4
+ import tempfile
5
 
6
  # 🎀 Speech to Text
7
  stt = pipeline("automatic-speech-recognition", model="openai/whisper-base")
8
 
9
+ # 🌍 Translation (FIXED)
10
+ translator = pipeline(
11
+ "translation",
12
+ model="facebook/nllb-200-distilled-600M"
13
+ )
14
 
15
 
16
+ def translate(audio):
17
 
18
+ # 1. speech β†’ text
19
  text = stt(audio)["text"]
20
 
21
+ # 2. translation (simple safe version)
22
+ translated = translator(text)[0]["translation_text"]
 
 
 
 
 
23
 
24
+ # 3. fake same voice output (RVC not included yet)
25
+ return translated, audio
26
 
27
 
28
  iface = gr.Interface(
29
+ fn=translate,
30
  inputs=gr.Audio(type="filepath"),
31
  outputs=[
32
+ gr.Textbox(),
33
+ gr.Audio()
34
  ],
35
+ title="Audio Translator FIXED"
36
  )
37
 
38
  iface.launch()