My first app goes with error i need a help

hello i need a help on page 3 it runs well at ‘streamlit run page3.py’ and tts goes well but in the app i deploy it doesn’t work and if i add pyaudio in the requirements it goes error like this


and if i don’t add pyaudio it goes like this

this is my first project at github and streamlit and i can’t solve the problem :frowning_face:
this link is my app

and this link is my github link

i’m not sure the link works well i’m waiting for experts to help me :smile:
oh the github link you should go to the master branches…

1 Like

pyaudio had additional, non-Python dependencies.

1 Like

Thanks for helping me i will try later thank you!! :blush:

2 Likes

o…k i solve the first problem the management windows that i cannot build wheel for pyaudio but the second one Os problem is still keep going is there any code problem that i used? i just try the ai chat bot using both voice and text avaliable with gemini api it works with the error sign but i want to fix it… :sweat_smile:

import streamlit as st
import speech_recognition as sr
import pyttsx3
import google.generativeai as genai

genai.configure(api_key=“API KEY”)

generation_config = {
“temperature”: 0.9,
“top_p”: 1,
“top_k”: 1,
“max_output_tokens”: 2048,
}

safety_settings = [
{
“category”: “HARM_CATEGORY_HARASSMENT”,
“threshold”: “BLOCK_MEDIUM_AND_ABOVE”
},
{
“category”: “HARM_CATEGORY_HATE_SPEECH”,
“threshold”: “BLOCK_MEDIUM_AND_ABOVE”
},
{
“category”: “HARM_CATEGORY_SEXUALLY_EXPLICIT”,
“threshold”: “BLOCK_MEDIUM_AND_ABOVE”
},
{
“category”: “HARM_CATEGORY_DANGEROUS_CONTENT”,
“threshold”: “BLOCK_MEDIUM_AND_ABOVE”
},
]

model = genai.GenerativeModel(model_name=“gemini-1.0-pro”,
generation_config=generation_config,
safety_settings=safety_settings)

def main():
st.title(" :cat: 스무고개")
st.header(" 주제는 동물입니다.")
st.write(“5번의 기회를 통해 어떠한 동물일지 맞춰보아요!”)

def text_to_speech(text):
    engine = pyttsx3.init()
    engine.say(text)
    engine.runAndWait()


# 음성 입력을 위한 함수
def get_audio_input():
    r = sr.Recognizer()

    with sr.Microphone() as source:
        audio = r.listen(source)

    # 구글 웹 음성 API로 인식하기 
    try:
        print("Google Speech Recognition thinks you said : " + r.recognize_google(audio, language='ko'))
        return r.recognize_google(audio, language='ko')
    except sr.UnknownValueError as e:
        print("Google Speech Recognition could not understand audio".format(e))
        return None
    except sr.RequestError as e:
        print("Could not request results from Google Speech Recognition service; {0}".format(e))
        return None

# 챗봇 응답을 얻는 함수
def get_chatbot_response(user_input):
    if "chat_session" not in st.session_state:
        st.session_state["chat_session"] = model.start_chat(history=[])

    ai_response = st.session_state.chat_session.send_message(user_input)
    return ai_response.text



 # User input handling (text and speech)
user_input_type = st.radio("입력 방식:", ("음성", "텍스트"))


if user_input_type == "음성":
    if st.button("마이크 켜기", key="mic_button_speech"):  # Unique key for speech input
        user_input = get_audio_input()
        if user_input is not None:
            st.text(f"사용자: {user_input}")
            chatbot_response = get_chatbot_response(user_input)
            st.text(f"AI: {chatbot_response}")
            text_to_speech(chatbot_response)
else:
    user_input = st.text_input("사용자 질문:")
    if user_input:
        st.text(f"사용자: {user_input}")
        chatbot_response = get_chatbot_response(user_input)
        st.text(f"AI: {chatbot_response}")
        text_to_speech(chatbot_response)

if name == “main”:
main()

st.page_link(“home.py”, label=“메인으로 돌아가기”, icon=“:house:”)
st.page_link(“pages/page1.py”, label=“씨앗 키우기”, icon=“:seedling:”)

this is the whole code where i get the error

oh i add espeak in the packages.txt the text input doesn’t occur the error but it still doesen’t came out with tts. and when i try to use voice chat it occur the error like this

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.