<Error>> ModuleNotFoundError: This app has encountered an error.

I’m trying to deploy a Python file below as URL, and it works fine locally. (w/ Private IP)
However it doesn’t work with deploying it outside as I keep facing errors.

Could you please advise tips to fix it?
As I’m not familiar with such issues…
Thank you in advance.


Uploading a Python file >Git hub >Streamlit
<Error>

ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 554, in _run_script
    exec(code, module.__dict__)File "app.py", line 2, in <module>
    from google.cloud import texttospeech

import os
from google.cloud import texttospeech

import io
import streamlit as st

os.environ[‘GOOGLE_APPLICATION_CREDENTIALS’] = ‘C:\Users\Shota Uwabo\secret.json’

def synthesize_speech(text, lang=‘English’, gender=‘Neutral’):
gender_type = {
‘Male’:texttospeech.SsmlVoiceGender.MALE,
‘Female’:texttospeech.SsmlVoiceGender.FEMALE,
‘Neutral’:texttospeech.SsmlVoiceGender.NEUTRAL
}

lang_code = {
‘English’: ‘en-US’,
‘日本語’: ‘ja-JP’
}

#lang = ‘English’
#gender = ‘Neutral’
#text = “Hello I’m John Thirdfield junior from Jacksonville Florida. Oh That’ my super hero”

client = texttospeech.TextToSpeechClient()

synthesis_input = texttospeech.SynthesisInput(text=text)

voice = texttospeech.VoiceSelectionParams(
language_code=lang_code[lang], ssml_gender=gender_type[gender]
)

audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3
)

response = client.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
return response

st.title(‘Audio Output App’)

st.markdown(‘### データ準備’)

input_option = st.selectbox(
‘Select input data’,
(‘Input directly’, ‘Text file’)
)
input_data = None

if input_option == ‘Input directly’:
input_data = st.text_area(‘Please input text here.’, ‘Hello, this is for testing.’)
else:
uploaded_file = st.file_uploader(‘Please upload a text file.’, [‘txt’])
if uploaded_file is not None:
content = uploaded_file.read()
input_data = content.decode()

if input_data is not None:
st.write(‘入力されたデータ’)
st.write(input_data)
st.markdown(‘### パラーメータ設定’)
st.subheader(‘Language & Speaker setting’)

lang = st.selectbox(
    'Please select the language',
    ('日本語','English')
)
gender = st.selectbox(
    'Please select the speaker',
    ('Neutral', 'Male', 'Female')
)
st.markdown('### 音声合成')
st.write('Okay to proceed?')
if st.button('Play♪'):
    comment = st.empty()
    comment.write('Start Playing')
    response = synthesize_speech(input_data, lang=lang, gender=gender)
    ##音声再生↓
    st.audio(response.audio_content)
    comment.write('Completed!!')

Requirements.txt

streamlit==1.10.0

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