Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,17 @@ def autoplay_audio(exported_audio):
|
|
| 22 |
md,
|
| 23 |
unsafe_allow_html=True,
|
| 24 |
)
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
#model = whisper.load_model("base")
|
| 27 |
client = OpenAI()
|
| 28 |
st.title("Whisper App")
|
|
@@ -43,14 +53,8 @@ if len(audio) > 0:
|
|
| 43 |
else:
|
| 44 |
st.write(f'The file {filepath} does not exist.')
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
input = f.read()
|
| 49 |
-
transcript = client.audio.transcriptions.create(
|
| 50 |
-
model="whisper-1",
|
| 51 |
-
file=input
|
| 52 |
-
)
|
| 53 |
-
st.write(transcript)
|
| 54 |
|
| 55 |
|
| 56 |
# To get audio properties, use pydub AudioSegment properties:
|
|
|
|
| 22 |
md,
|
| 23 |
unsafe_allow_html=True,
|
| 24 |
)
|
| 25 |
+
|
| 26 |
+
def transcribe_audio(filepath):
|
| 27 |
+
client = OpenAI()
|
| 28 |
+
audio_file = open(filepath, "rb")
|
| 29 |
+
transcript = client.audio.transcriptions.create(
|
| 30 |
+
model="whisper-1",
|
| 31 |
+
file=audio_file
|
| 32 |
+
)
|
| 33 |
+
audio_file.close()
|
| 34 |
+
return transcript
|
| 35 |
+
|
| 36 |
#model = whisper.load_model("base")
|
| 37 |
client = OpenAI()
|
| 38 |
st.title("Whisper App")
|
|
|
|
| 53 |
else:
|
| 54 |
st.write(f'The file {filepath} does not exist.')
|
| 55 |
|
| 56 |
+
transcribe_audio(filepath)
|
| 57 |
+
st.write(transcript)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
# To get audio properties, use pydub AudioSegment properties:
|