Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a bug maybe #22

Open
wangzhaoyang-508 opened this issue May 29, 2024 · 2 comments
Open

a bug maybe #22

wangzhaoyang-508 opened this issue May 29, 2024 · 2 comments

Comments

@wangzhaoyang-508
Copy link

I can run this in my PC

import streamlit as st
from audiorecorder import audiorecorder
import whisper

# st.title("Audio Recorder")

# if 'audio' not in st.session_state:
#     st.session_state.audio = None

# 使用录音组件
audio1 = audiorecorder("Click to record", "Click to stop recording", key='1')

# 检查是否录音完成
# if audio:
#     st.session_state.audio = audio
#     print(type(audio))

#     # 在前端播放音频
#     st.audio(audio.export().read())

#     # 保存音频
#     audio.export("/mnt/workspace/projects/whisper/audio.wav", format="wav")

#     # 加载模型并进行转录
#     model = whisper.load_model("/mnt/workspace/projects/whisper/base.pt")
#     result = model.transcribe("/mnt/workspace/projects/whisper/audio.wav")
#     answer = result["text"]
#     print('answer:', answer)
#     st.write('Transcription:', answer)

but in a cluster server there is a ERROR

Traceback (most recent call last):
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.dict)
File "/mnt/workspace/projects/Langchain-Chatchat/tests/whisper.py", line 11, in
audio1 = audiorecorder("Click to record", "Click to stop recording", key='1')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/audiorecorder/init.py", line 25, in audiorecorder
base64_audio = _component_func(start_prompt=start_prompt, stop_prompt=stop_prompt, pause_prompt=pause_prompt, show_visualizer=show_visualizer, key=key, default=b"")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/components/v1/components.py", line 80, in call
return self.create_instance(*args, default=default, key=key, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/runtime/metrics_util.py", line 396, in wrapped_func
result = non_optional_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/components/v1/components.py", line 241, in create_instance
return_value = marshall_component(dg, element)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/components/v1/components.py", line 212, in marshall_component
component_state = register_widget(
^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/runtime/state/widgets.py", line 161, in register_widget
return register_widget_from_metadata(metadata, ctx, widget_func_name, element_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/runtime/state/widgets.py", line 194, in register_widget_from_metadata
raise DuplicateWidgetID(
streamlit.errors.DuplicateWidgetID: There are multiple widgets with the same key='1'.

@RajGothi
Copy link

you need to pass unique key to every audio for that... that error is becuase of streamlit.

@theevann
Copy link
Owner

theevann commented Jul 2, 2024

Hello,
I don't think the error is related to this component.
Do you have other component on the server side code ? Did you try with different keys ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants