Open stonelazy opened 3 years ago
` complete_audio_chunk = pydub.AudioSegment.empty() while True: if webrtc_ctx.audio_receiver: sound_chunk = pydub.AudioSegment.empty() try: audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1) except queue.Empty: time.sleep(0.1) status_indicator.write("No frame arrived.") continue
status_indicator.write("Running. Say something!") for idx, audio_frame in enumerate(audio_frames): sound = pydub.AudioSegment( data=audio_frame.to_ndarray().tobytes(), sample_width=audio_frame.format.bytes, frame_rate=audio_frame.sample_rate, channels=len(audio_frame.layout.channels), ) op = str(idx) + "omg" + str(audio_frame.to_ndarray().shape) text_output.write(op) sound_chunk += sound complete_audio_chunk += sound else: status_indicator.write("Audio Receiver is not set. Abort.") break complete_audio_chunk.export("/home/kp/temp/audio_file.wav", format="wav") logger.info("ENEDNEND call") st.write("end call")
`
I tried the above code, (copied from https://github.com/whitphx/streamlit-webrtc-example/blob/main/app.py). Only audio frames are of interest for me. But, audio is not saved in audio_file.wav at all.
https://github.com/whitphx/streamlit-webrtc/issues/357 might help.
`
complete_audio_chunk = pydub.AudioSegment.empty() while True: if webrtc_ctx.audio_receiver: sound_chunk = pydub.AudioSegment.empty() try: audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1) except queue.Empty: time.sleep(0.1) status_indicator.write("No frame arrived.") continue
`
I tried the above code, (copied from https://github.com/whitphx/streamlit-webrtc-example/blob/main/app.py). Only audio frames are of interest for me. But, audio is not saved in audio_file.wav at all.