Spaces:
Sleeping
Sleeping
have the working mic code
Browse files- app.py +29 -0
- flow.txt +0 -0
- working.py +28 -0
app.py
CHANGED
|
@@ -5,3 +5,32 @@ def greet(name):
|
|
| 5 |
|
| 6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
| 8 |
+
|
| 9 |
+
# transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
|
| 10 |
+
|
| 11 |
+
# def transcribe(stream, new_chunk):
|
| 12 |
+
# sr, y = new_chunk
|
| 13 |
+
|
| 14 |
+
# # Convert to mono if stereo
|
| 15 |
+
# if y.ndim > 1:
|
| 16 |
+
# y = y.mean(axis=1)
|
| 17 |
+
|
| 18 |
+
# y = y.astype(np.float32)
|
| 19 |
+
# y /= np.max(np.abs(y))
|
| 20 |
+
|
| 21 |
+
# if stream is not None:
|
| 22 |
+
# stream = np.concatenate([stream, y])
|
| 23 |
+
# else:
|
| 24 |
+
# stream = y
|
| 25 |
+
|
| 26 |
+
# # Return the stream as state and a string representation of the array for display
|
| 27 |
+
# return stream, str(stream)
|
| 28 |
+
|
| 29 |
+
# demo = gr.Interface(
|
| 30 |
+
# transcribe,
|
| 31 |
+
# ["state", gr.Audio(sources=["microphone"], streaming=True)],
|
| 32 |
+
# ["state", "text"],
|
| 33 |
+
# live=True,
|
| 34 |
+
# )
|
| 35 |
+
|
| 36 |
+
# demo.launch()
|
flow.txt
ADDED
|
File without changes
|
working.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
|
| 2 |
+
|
| 3 |
+
# def transcribe(stream, new_chunk):
|
| 4 |
+
# sr, y = new_chunk
|
| 5 |
+
|
| 6 |
+
# # Convert to mono if stereo
|
| 7 |
+
# if y.ndim > 1:
|
| 8 |
+
# y = y.mean(axis=1)
|
| 9 |
+
|
| 10 |
+
# y = y.astype(np.float32)
|
| 11 |
+
# y /= np.max(np.abs(y))
|
| 12 |
+
|
| 13 |
+
# if stream is not None:
|
| 14 |
+
# stream = np.concatenate([stream, y])
|
| 15 |
+
# else:
|
| 16 |
+
# stream = y
|
| 17 |
+
|
| 18 |
+
# # Return the stream as state and a string representation of the array for display
|
| 19 |
+
# return stream, str(stream)
|
| 20 |
+
|
| 21 |
+
# demo = gr.Interface(
|
| 22 |
+
# transcribe,
|
| 23 |
+
# ["state", gr.Audio(sources=["microphone"], streaming=True)],
|
| 24 |
+
# ["state", "text"],
|
| 25 |
+
# live=True,
|
| 26 |
+
# )
|
| 27 |
+
|
| 28 |
+
# demo.launch()
|