andito HF staff commited on
Commit
431d59e
β€’
1 Parent(s): 8606e7e

update gradio

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +18 -20
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: πŸ“š
4
  colorFrom: yellow
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.44.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
4
  colorFrom: yellow
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.0.0b3
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py CHANGED
@@ -1,25 +1,23 @@
1
- import numpy as np
2
-
3
  import gradio as gr
4
 
5
- def reverse_audio(audio):
6
- sr, data = audio
7
- return (sr, np.flipud(data))
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- input_audio = gr.Audio(
10
- sources=["microphone"],
11
- waveform_options=gr.WaveformOptions(
12
- waveform_color="#01C6FF",
13
- waveform_progress_color="#0066B4",
14
- skip_length=2,
15
- show_controls=False,
16
- ),
17
- )
18
- demo = gr.Interface(
19
- fn=reverse_audio,
20
- inputs=input_audio,
21
- outputs="audio"
22
- )
23
 
24
  if __name__ == "__main__":
25
- demo.launch()
 
 
 
1
  import gradio as gr
2
 
3
+ t = "the big blue " * 5
4
+ i = 0
5
+
6
+ def transcribe(audio: str, state: str):
7
+ global i
8
+ next_chunk = t[i:i+1]
9
+ i += 1
10
+ state += " " + next_chunk
11
+ return audio, state
12
+
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# New Audio Streaming In 🎀")
15
+ inp = gr.Audio(sources=["microphone"], type="filepath")
16
+ out = gr.Audio(type="filepath", autoplay=True)
17
+ transcription = gr.State(value="")
18
+ clear = gr.Button("Clear")
19
 
20
+ inp.stream(transcribe, [inp, transcription], [out, transcription], time_limit=10, stream_every=0.5)
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  if __name__ == "__main__":
23
+ demo.launch()