themeetjani's picture
Rename sp.py to app.py
de28e10 verified
raw
history blame contribute delete
794 Bytes
import streamlit as st
from streamlit import session_state
import tempfile
from pathlib import Path
st.set_page_config(
page_title="Speech Recognision",
page_icon="πŸ“ˆ",
)
from openai import OpenAI
client = OpenAI()
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
# Make temp file path from uploaded file
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
fp = Path(tmp_file.name)
fp.write_bytes(uploaded_file.getvalue())
print(tmp_file.name,"path_")
audio_file= open(tmp_file.name, "rb")
transcript_english = client.audio.translations.create(
model="whisper-1",
file=audio_file,temperature = 0)
st.text_area("Transcription", value=transcript_english.text)