cahya commited on
Commit
85e039a
1 Parent(s): cac3bb3

add transcription and translation text box

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -11,7 +11,7 @@ from mtranslate import translate
11
 
12
  MODEL_NAME = "cahya/whisper-medium-id" #this always needs to stay in line 8 :D sorry for the hackiness
13
  lang = "id"
14
- title = "indonesian Whisperer"
15
  description = "Cross Language Speech to Speech using OpenAI Whisper and Coqui TTS"
16
  info = "more info at [indonesian Whisperer](https://github.com/cahya-wirawan/indonesian-whisperer)"
17
  badge = "https://img.shields.io/badge/Powered%20by-Indonesian%20Whisperer-red"
@@ -53,14 +53,14 @@ coquiTTS = CoquiTTS()
53
 
54
  def tts(language: str, audio_file: str):
55
  print(f"### {datetime.now()} TTS", language, audio_file)
56
- transcribed = transcribe(None, audio_file)
57
- print(f"### {datetime.now()} transcribed:", transcribed)
58
- translation = translate(transcribed, language, "id")
59
  # return output
60
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
61
  coquiTTS.get_tts(translation, fp, speaker={"language": language})
62
  print(f"### {datetime.now()} fp.name:", fp.name)
63
- return fp.name
64
 
65
 
66
  with gr.Blocks() as blocks:
@@ -79,7 +79,10 @@ with gr.Blocks() as blocks:
79
  )
80
  with gr.Row(): # mobile_collapse=False
81
  submit = gr.Button("Submit", variant="primary")
82
- audio = gr.Audio(label="Output", interactive=False)
 
 
 
83
  memory = psutil.virtual_memory()
84
  gr.Markdown(info)
85
  system_status = info = f"""
@@ -94,7 +97,7 @@ with gr.Blocks() as blocks:
94
  submit.click(
95
  tts,
96
  [radio, upload],
97
- [audio],
98
  )
99
  radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio)
100
 
 
11
 
12
  MODEL_NAME = "cahya/whisper-medium-id" #this always needs to stay in line 8 :D sorry for the hackiness
13
  lang = "id"
14
+ title = "Indonesian Whisperer"
15
  description = "Cross Language Speech to Speech using OpenAI Whisper and Coqui TTS"
16
  info = "more info at [indonesian Whisperer](https://github.com/cahya-wirawan/indonesian-whisperer)"
17
  badge = "https://img.shields.io/badge/Powered%20by-Indonesian%20Whisperer-red"
 
53
 
54
  def tts(language: str, audio_file: str):
55
  print(f"### {datetime.now()} TTS", language, audio_file)
56
+ transcription = transcribe(None, audio_file)
57
+ print(f"### {datetime.now()} transcribed:", transcription)
58
+ translation = translate(transcription, language, "id")
59
  # return output
60
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
61
  coquiTTS.get_tts(translation, fp, speaker={"language": language})
62
  print(f"### {datetime.now()} fp.name:", fp.name)
63
+ return transcription, translation, fp.name
64
 
65
 
66
  with gr.Blocks() as blocks:
 
79
  )
80
  with gr.Row(): # mobile_collapse=False
81
  submit = gr.Button("Submit", variant="primary")
82
+ with gr.Column():
83
+ text_source = gr.Textbox()
84
+ text_target = gr.Textbox()
85
+ audio = gr.Audio(label="Output", interactive=False)
86
  memory = psutil.virtual_memory()
87
  gr.Markdown(info)
88
  system_status = info = f"""
 
97
  submit.click(
98
  tts,
99
  [radio, upload],
100
+ [text_source, text_target, audio],
101
  )
102
  radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio)
103