Spaces:
Sleeping
Sleeping
Commit ·
48eebae
1
Parent(s): 4ccd185
Update app.py
Browse files8 unmodified lines91011128 unmodified lines# Perform inference using the loaded modelresult = model(input_text)st.write("Prediction:", result[0]['label'], "| Score:", result[0]['score'])8 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960618 unmodified lines# Perform inference using the loaded modelresult = model(input_text)st.write("Prediction:", result[0]['label'], "| Score:", result[0]['score'])###def recording_storing():chunk = 1024 # Record in chunks of 1024 samplessample_format = pyaudio.paInt16 # 16 bits per samplechannels = 1fs = 44100 # Record at 44100 samples per secondseconds = 4# filename = "output.wav"p = pyaudio.PyAudio() # Create an interface to PortAudioprint('Recording')stream = p.open(format=sample_format,channels=channels,rate=fs,frames_per_buffer=chunk,input=True)frames = [] # Initialize array to store frames# Store data in chunks for 3 secondsfor i in range(0, int(fs / chunk * seconds)):data = stream.read(chunk)frames.append(data)# Stop and close the streamstream.stop_stream()stream.close()# Terminate the PortAudio interfacep.terminate()print('Finished recording')# Save the recorded data as a WAV filewf = wave.open(filename, 'wb')wf.setnchannels(channels)wf.setsampwidth(p.get_sample_size(sample_format))wf.setframerate(fs)wf.writeframes(b''.join(frames))wf.close()return "recorded"audio = recording_storing()print(audio)
app.py+49