aliabd HF staff commited on
Commit
779f00d
·
1 Parent(s): 442328f

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +6 -7
  2. requirements.txt +1 -0
  3. run.py +27 -0
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Stream Audio Main
3
- emoji:
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 3.6
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: stream_audio_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.6
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ https://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import time
4
+
5
+ def add_to_stream(audio, instream):
6
+ time.sleep(1)
7
+ if audio is None:
8
+ return gr.update(), instream
9
+ if instream is None:
10
+ ret = audio
11
+ else:
12
+ ret = (audio[0], np.concatenate((instream[1], audio[1])))
13
+ return ret, ret
14
+
15
+
16
+ with gr.Blocks() as demo:
17
+ inp = gr.Audio(source="microphone")
18
+ out = gr.Audio()
19
+ stream = gr.State()
20
+ clear = gr.Button("Clear")
21
+
22
+ inp.stream(add_to_stream, [inp, stream], [out, stream])
23
+ clear.click(lambda: [None, None, None], None, [inp, out, stream])
24
+
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()