Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,14 +10,15 @@ from pydub import AudioSegment
|
|
10 |
PASSWORDS = os.environ["PASSWORD"].split(",")
|
11 |
ROOT_PASSWORDS = os.environ["ROOT_PASSWORD"].split(",")
|
12 |
|
13 |
-
run_transcription = modal.Function.lookup(
|
|
|
|
|
14 |
|
15 |
st.set_page_config(page_title="Speech to Text Transcription App")
|
16 |
|
17 |
|
18 |
-
@st.cache(show_spinner=False)
|
19 |
def transcribe(url, audio_b64, cutoff):
|
20 |
-
return run_transcription.
|
21 |
|
22 |
|
23 |
def password_is_correct(password):
|
@@ -68,17 +69,15 @@ def run():
|
|
68 |
submit_button = col2.button(
|
69 |
label="⚡ Transkribieren"
|
70 |
+ (" (Zugriffscode inkorrekt)" if not password_is_correct(password) else ""),
|
71 |
-
disabled=(
|
72 |
-
not password_is_correct(password) or (not audio_file and not url) or running
|
73 |
-
),
|
74 |
)
|
75 |
|
76 |
cutoff = audio_b64 = None
|
|
|
77 |
if audio_file or url:
|
78 |
# with st.expander(("Audio" if audio_file else "Video") + " abspielen"):
|
79 |
if audio_file:
|
80 |
st.audio(audio_file)
|
81 |
-
cutoff = None if password in ROOT_PASSWORDS else 60_000
|
82 |
audio_file = AudioSegment.from_file(audio_file)[:cutoff]
|
83 |
audio_b64 = base64.b64encode(audio_file.export().read()).decode("ascii")
|
84 |
if url:
|
@@ -118,5 +117,5 @@ try:
|
|
118 |
except Exception as e:
|
119 |
logger.error(e)
|
120 |
st.error(
|
121 |
-
"Leider ist ein unerwarter Fehler aufgetreten. Ich kann mir das Problem sofort ansehen, Sie erreichen mich unter alexander
|
122 |
)
|
|
|
10 |
PASSWORDS = os.environ["PASSWORD"].split(",")
|
11 |
ROOT_PASSWORDS = os.environ["ROOT_PASSWORD"].split(",")
|
12 |
|
13 |
+
run_transcription = modal.Function.lookup(
|
14 |
+
"ffpub-transcription", "run_transcription", environment_name="main"
|
15 |
+
)
|
16 |
|
17 |
st.set_page_config(page_title="Speech to Text Transcription App")
|
18 |
|
19 |
|
|
|
20 |
def transcribe(url, audio_b64, cutoff):
|
21 |
+
return run_transcription.remote(url=url, audio_b64=audio_b64, cutoff=cutoff, language=None)
|
22 |
|
23 |
|
24 |
def password_is_correct(password):
|
|
|
69 |
submit_button = col2.button(
|
70 |
label="⚡ Transkribieren"
|
71 |
+ (" (Zugriffscode inkorrekt)" if not password_is_correct(password) else ""),
|
72 |
+
disabled=(not password_is_correct(password) or (not audio_file and not url) or running),
|
|
|
|
|
73 |
)
|
74 |
|
75 |
cutoff = audio_b64 = None
|
76 |
+
cutoff = 60_000_000 if password in ROOT_PASSWORDS else 60_000
|
77 |
if audio_file or url:
|
78 |
# with st.expander(("Audio" if audio_file else "Video") + " abspielen"):
|
79 |
if audio_file:
|
80 |
st.audio(audio_file)
|
|
|
81 |
audio_file = AudioSegment.from_file(audio_file)[:cutoff]
|
82 |
audio_b64 = base64.b64encode(audio_file.export().read()).decode("ascii")
|
83 |
if url:
|
|
|
117 |
except Exception as e:
|
118 |
logger.error(e)
|
119 |
st.error(
|
120 |
+
"Leider ist ein unerwarter Fehler aufgetreten. Ich kann mir das Problem sofort ansehen, Sie erreichen mich unter alexander@ff.pub"
|
121 |
)
|