wvle commited on
Commit
d68492b
·
1 Parent(s): b326f7b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def speech_youtube(x):
2
+ data = pytube.YouTube(x)
3
+ audio = data.streams.get_audio_only()
4
+ text = model.transcribe(audio.download())
5
+ return text['text']
6
+
7
+ def speech_file(x):
8
+ text = model.transcribe(x)
9
+ return text['text']
10
+
11
+ def speech_record(x):
12
+ text = model.transcribe(x)
13
+ return text['text']
14
+
15
+ css = ".gradio-container {background-color: blue}"
16
+
17
+ with gr.Blocks(css = css) as demo:
18
+ gr.Markdown(
19
+ """
20
+ # Speech to Text Transcriptions!
21
+ Start typing below to see the output.
22
+ """)
23
+ with gr.Tab("YouTube"):
24
+ audio_input = gr.Textbox(label="YouTube Link", placeholder="paste the youtube link here")
25
+ text_output = gr.Textbox(label="Transcription")
26
+ youtube_button = gr.Button("Transcribe")
27
+ with gr.Tab("Audio File"):
28
+ with gr.Row():
29
+ audio_input2 = gr.Audio(label="Audio File", type="filepath")
30
+ text_output2 = gr.Textbox(label="Transcription")
31
+ file_button = gr.Button("Transcribe")
32
+ with gr.Tab("Record"):
33
+ with gr.Row():
34
+ audio_input3 = gr.Audio(label="Input Audio", source="microphone", type="filepath")
35
+ text_output3 = gr.Textbox(label="Transcription")
36
+ rec_button = gr.Button("Transcribe")
37
+
38
+ youtube_button.click(speech_youtube, inputs=audio_input, outputs=text_output)
39
+ file_button.click(speech_file, inputs=audio_input2, outputs=text_output2)
40
+ rec_button.click(speech_record, inputs=audio_input3, outputs=text_output3)
41
+
42
+ demo.launch()