LiuPengNGP commited on
Commit
53fa185
·
1 Parent(s): 0876449
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -1,17 +1,24 @@
1
  import gradio as gr
 
 
2
 
3
- def process_image(image):
4
- # Placeholder function to process the image
5
- # For now, it just returns the image as is
6
- return image
7
 
8
- # Create a Gradio interface
9
- iface = gr.Interface(
10
- fn=process_image, # Function to process the image
11
- inputs=gr.Image(source="webcam", tool="editor"), # Capture image from webcam
12
- outputs="image", # Output type is an image
13
- live=True # Enable live webcam feed
14
- )
15
 
16
- # Launch the interface
17
- iface.launch()
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+ import time
4
 
5
+ pipe = pipeline("automatic-speech-recognition")
 
 
 
6
 
7
+ def transcribe(audio, state=""):
8
+ print(audio)
9
+ time.sleep(2)
10
+ text = pipe(audio)["text"]
11
+ state += text + " "
12
+ return state, state
 
13
 
14
+
15
+ with gr.Blocks() as demo:
16
+ state = gr.State(value="")
17
+ with gr.Row():
18
+ with gr.Column():
19
+ audio = gr.Audio(source="microphone", type="filepath")
20
+ with gr.Column():
21
+ textbox = gr.Textbox()
22
+ audio.stream(fn=transcribe, inputs=[audio, state], outputs=[textbox, state])
23
+
24
+ demo.launch(debug=True)