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

add microphone

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -51,9 +51,9 @@ default_lang = "en"
51
  coquiTTS = CoquiTTS()
52
 
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
@@ -70,19 +70,20 @@ with gr.Blocks() as blocks:
70
  gr.Markdown(description)
71
  with gr.Row():# equal_height=False
72
  with gr.Column():# variant="panel"
73
- upload = gr.Audio(label="Upload", source="upload", type="filepath", optional=True)
74
- print("upload:", upload)
 
75
  radio = gr.Radio(
76
- label="Language",
77
  choices=LANGUAGES,
78
  value=default_lang
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"""
@@ -96,7 +97,7 @@ with gr.Blocks() as blocks:
96
  # actions
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)
 
51
  coquiTTS = CoquiTTS()
52
 
53
 
54
+ def tts(language: str, audio_microphone: str, audio_file: str):
55
  print(f"### {datetime.now()} TTS", language, audio_file)
56
+ transcription = transcribe(audio_microphone, audio_file)
57
  print(f"### {datetime.now()} transcribed:", transcription)
58
  translation = translate(transcription, language, "id")
59
  # return output
 
70
  gr.Markdown(description)
71
  with gr.Row():# equal_height=False
72
  with gr.Column():# variant="panel"
73
+ audio_microphone = gr.Audio(label="Microphone", source="microphone", type="filepath", optional=True)
74
+ audio_upload = gr.Audio(label="Upload", source="upload", type="filepath", optional=True)
75
+ print("upload:", audio_upload)
76
  radio = gr.Radio(
77
+ label="Target Language",
78
  choices=LANGUAGES,
79
  value=default_lang
80
  )
81
  with gr.Row(): # mobile_collapse=False
82
  submit = gr.Button("Submit", variant="primary")
83
  with gr.Column():
84
+ text_source = gr.Textbox(label="Source Language")
85
+ text_target = gr.Textbox(label="Target Language")
86
+ audio = gr.Audio(label="Target Audio", interactive=False)
87
  memory = psutil.virtual_memory()
88
  gr.Markdown(info)
89
  system_status = info = f"""
 
97
  # actions
98
  submit.click(
99
  tts,
100
+ [radio, audio_microphone, audio_upload],
101
  [text_source, text_target, audio],
102
  )
103
  radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio)