Spaces:
Running
Running
Create app_1.py
Browse files
app_1.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app_1.py
|
2 |
+
|
3 |
+
# VERTAAL APP EAGLE SHELTER
|
4 |
+
# Versie d.d. 19-03-2024
|
5 |
+
# EVERNOTE:
|
6 |
+
# EAGLE SHELTER VERTAAL APP (EIGENLIJK TRANSCRIPTIE APP !) - CONNY ARIËNS - Can I use the microphone in a Streamlit application running on Hugging Face Spaces? - YES ! - POE WEB-SEARCH - 19-03-2024 !!!!! !!!!!
|
7 |
+
# https://www.evernote.com/shard/s313/nl/41973486/a5777de0-40b5-4b88-8f7e-829c758fff92/
|
8 |
+
# EAGLE SHELTER VERTAAL APP (EIGENLIJK TRANSCRIPTIE APP !) - CONNY ARIËNS - Can I use the microphone in a Streamlit application running on Hugging Face Spaces? - YES ! - POE WEB-SEARCH - 19-03-2024 !!!!! !!!!!
|
9 |
+
# https://poe.com/s/mlDEoHWYvbk11hQ5AE7z
|
10 |
+
|
11 |
+
# example of how to configure the microphone input using the pyaudio library in Python:
|
12 |
+
|
13 |
+
import streamlit as st
|
14 |
+
import pyaudio
|
15 |
+
def configure_microphone_input():
|
16 |
+
# Create an instance of the PyAudio class
|
17 |
+
audio = pyaudio.PyAudio()
|
18 |
+
|
19 |
+
# Get the available input devices
|
20 |
+
device_count = audio.get_device_count()
|
21 |
+
input_devices = []
|
22 |
+
for i in range(device_count):
|
23 |
+
device_info = audio.get_device_info_by_index(i)
|
24 |
+
if device_info['maxInputChannels'] > 0:
|
25 |
+
input_devices.append(device_info)
|
26 |
+
|
27 |
+
# Print the available input devices
|
28 |
+
st.write("Available input devices:")
|
29 |
+
for i, device in enumerate(input_devices):
|
30 |
+
st.write(f"{i+1}. {device['name']}")
|
31 |
+
# Select the desired input device
|
32 |
+
# device_index = st.number_input("Enter the index of the input device you want to use:", min_value=1, max_value=len(input_devices), value=1, step=1) - 1
|
33 |
+
device_index = 0 # st.number_input("Enter the index of the input device you want to use:", min_value=0, max_value=len(input_devices), value=0, step=1) - 1
|
34 |
+
|
35 |
+
# Configure the microphone input
|
36 |
+
stream = audio.open(format=pyaudio.paInt16,
|
37 |
+
channels=1,
|
38 |
+
rate=44100,
|
39 |
+
input=True,
|
40 |
+
input_device_index=device_index,
|
41 |
+
frames_per_buffer=1024)
|
42 |
+
# Start recording
|
43 |
+
st.write("Recording started...")
|
44 |
+
frames = []
|
45 |
+
while True:
|
46 |
+
data = stream.read(1024)
|
47 |
+
frames.append(data)
|
48 |
+
|
49 |
+
# Stop recording
|
50 |
+
st.write("Recording stopped.")
|
51 |
+
stream.stop_stream()
|
52 |
+
stream.close()
|
53 |
+
audio.terminate()
|
54 |
+
|
55 |
+
# Process the recorded audio frames as needed
|
56 |
+
# ...
|
57 |
+
|
58 |
+
# Streamlit app
|
59 |
+
# def main():
|
60 |
+
st.title("Microphone Input Example")
|
61 |
+
# Configure microphone input
|
62 |
+
configure_microphone_input()
|
63 |
+
|
64 |
+
#if __name__ == "__main__":
|
65 |
+
# main()
|