Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,24 @@ import streamlit as st
|
|
2 |
from audiorecorder import audiorecorder
|
3 |
import openai
|
4 |
import os
|
|
|
5 |
|
6 |
# Nastavení OpenAI klíče
|
7 |
openai.api_key = os.environ['OPENAI_API_KEY']
|
8 |
|
9 |
-
def transcribe(
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Inicializace session state
|
15 |
if 'vignette' not in st.session_state:
|
@@ -19,7 +29,7 @@ if 'length' not in st.session_state:
|
|
19 |
st.session_state['length'] = 0
|
20 |
|
21 |
# Hlavní titulek aplikace
|
22 |
-
st.title("AI
|
23 |
st.markdown("Record your patient presentation and get the transcription.")
|
24 |
st.divider()
|
25 |
|
@@ -33,4 +43,4 @@ if len(audio) != st.session_state['length']:
|
|
33 |
st.session_state['vignette'] += transcript
|
34 |
|
35 |
# Zobrazení transkripce
|
36 |
-
st.session_state['vignette'] = st.text_area("
|
|
|
2 |
from audiorecorder import audiorecorder
|
3 |
import openai
|
4 |
import os
|
5 |
+
import tempfile
|
6 |
|
7 |
# Nastavení OpenAI klíče
|
8 |
openai.api_key = os.environ['OPENAI_API_KEY']
|
9 |
|
10 |
+
def transcribe(audio_bytes):
|
11 |
+
# Vytvoření dočasného souboru pro uložení audio dat
|
12 |
+
with tempfile.NamedTemporaryFile(suffix='.mp3', delete=False) as temp_audio_file:
|
13 |
+
temp_audio_file.write(audio_bytes)
|
14 |
+
temp_audio_file_path = temp_audio_file.name
|
15 |
+
|
16 |
+
# Otevření dočasného souboru a jeho předání modelu Whisper
|
17 |
+
with open(temp_audio_file_path, "rb") as audio_file:
|
18 |
+
transcript = openai.Audio.transcribe(
|
19 |
+
file=audio_file,
|
20 |
+
model="whisper-1"
|
21 |
+
)
|
22 |
+
return transcript["choices"][0]["text"]
|
23 |
|
24 |
# Inicializace session state
|
25 |
if 'vignette' not in st.session_state:
|
|
|
29 |
st.session_state['length'] = 0
|
30 |
|
31 |
# Hlavní titulek aplikace
|
32 |
+
st.title("AI Transcription for Healthcare Providers")
|
33 |
st.markdown("Record your patient presentation and get the transcription.")
|
34 |
st.divider()
|
35 |
|
|
|
43 |
st.session_state['vignette'] += transcript
|
44 |
|
45 |
# Zobrazení transkripce
|
46 |
+
st.session_state['vignette'] = st.text_area("Transcription", value=st.session_state['vignette'])
|