tbboukhari commited on
Commit
5ef621f
1 Parent(s): 333ace0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -14
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import gradio as gr
2
  import torch
3
  from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
@@ -77,20 +80,30 @@ def process_audio(audio_file, translate_language, tts_language):
77
  return f"An error occurred: {e}", None
78
 
79
  # Gradio Interface
80
- interface = gr.Interface(
81
- fn=process_audio,
82
- inputs=[
83
- gr.Audio(type="filepath", label="Upload or Record Audio"),
84
- gr.Dropdown(choices=list(languages.keys()), label="Translation Language "),
85
- gr.Dropdown(choices=list(languages.values()), label="TTS Synthesis Language (XTTS)")
86
- ],
87
- outputs=[
88
- gr.Textbox(label="Translated Text"),
89
- gr.Audio(label="Generated Audio")
90
- ],
91
- title="AI VOX LAB POC",
92
- description="Upload/record audio, translate, and get synthesized speech!"
93
- )
 
 
 
 
 
 
 
 
 
 
94
 
95
  # Launch the App
96
  if __name__ == "__main__":
 
1
+ import os
2
+ os.environ["TTS_ACCEPT_TOS"] = "1" # Add this line to accept the TOS
3
+
4
  import gradio as gr
5
  import torch
6
  from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
 
80
  return f"An error occurred: {e}", None
81
 
82
  # Gradio Interface
83
+ with gr.Blocks() as interface:
84
+ gr.Markdown("# AI VOX LAB POC")
85
+ gr.Markdown("Upload/record audio, translate, and get synthesized speech!")
86
+
87
+ # Add the image here
88
+ gr.Image(value="/Users/mac/Desktop/VOX_AI/logo_transparent_background.png", label="App Logo", show_label=False, width=700, height=250)
89
+
90
+ with gr.Row():
91
+ audio_input = gr.Audio(type="filepath", label="Upload or Record Audio")
92
+ translate_lang = gr.Dropdown(choices=list(languages.keys()), label="Translation Language")
93
+ tts_lang = gr.Dropdown(choices=list(languages.values()), label="TTS Synthesis Language")
94
+
95
+ with gr.Row():
96
+ translate_button = gr.Button("Translate and Synthesize")
97
+
98
+ with gr.Row():
99
+ text_output = gr.Textbox(label="Translated Text")
100
+ audio_output = gr.Audio(label="Generated Audio")
101
+
102
+ translate_button.click(
103
+ fn=process_audio,
104
+ inputs=[audio_input, translate_lang, tts_lang],
105
+ outputs=[text_output, audio_output]
106
+ )
107
 
108
  # Launch the App
109
  if __name__ == "__main__":