theevann / streamlit-audiorecorder

Audio recorder for streamlit
MIT License
128 stars 21 forks source link

JSONDecodeError with audiorecorder function #18

Closed ejmiddle closed 3 months ago

ejmiddle commented 10 months ago

Hey,

I have a problem using the audiorecorder function. After it has been working on the same system (MacOS), now I get the error message below. I cooked everything down to these two lines of code in a clean virtual environment with only streamlit audiorecorder.

'''from audiorecorder import audiorecorder audio = audiorecorder("Click to record something", "Click to stop recording")'''

Any ideas?

Thank you

JSONDecodeError: Expecting value: line 1 column 1 (char 0) Traceback: File "localpath/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script exec(code, module.dict) File "localpath/app/other_pages/app_transkription.py", line 24, in audio = audiorecorder("Click to record something", "Click to stop recording") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "localpath/.venv/lib/python3.11/site-packages/audiorecorder/init.py", line 27, in audiorecorder audio_segment = AudioSegment.from_file(BytesIO(b64decode(base64_audio))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "localpath/.venv/lib/python3.11/site-packages/pydub/audio_segment.py", line 728, in from_file info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "localpath/.venv/lib/python3.11/site-packages/pydub/utils.py", line 279, in mediainfo_json info = json.loads(output) ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None

theevann commented 10 months ago

Sorry, I just saw your issue. It looks like it could be an issue on the browser side... but without more info and testing it seems hard to debug...

goldenbubble2023 commented 9 months ago

@ejmiddle recommond you to check out if there are multiple virtual mic devices named iphone_cam on your system. I uesd to have errors as same as yours, not only on this but on calling Recorder (https://github.com/xiangyuecn/Recorder). Once you have vitual mic, whatever the default you set, the browser calls wrong one persistently in my case.