themeetjani commited on
Commit
18214ff
β€’
1 Parent(s): e654989

Upload sp.py

Browse files
Files changed (1) hide show
  1. sp.py +26 -0
sp.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit import session_state
3
+ import tempfile
4
+ from pathlib import Path
5
+
6
+ st.set_page_config(
7
+ page_title="Speech Recognision",
8
+ page_icon="πŸ“ˆ",
9
+ )
10
+ from openai import OpenAI
11
+ client = OpenAI()
12
+ uploaded_file = st.file_uploader("Choose a file")
13
+
14
+ if uploaded_file is not None:
15
+ # Make temp file path from uploaded file
16
+ with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
17
+ fp = Path(tmp_file.name)
18
+ fp.write_bytes(uploaded_file.getvalue())
19
+ print(tmp_file.name,"path_")
20
+ audio_file= open(tmp_file.name, "rb")
21
+ transcript_english = client.audio.translations.create(
22
+ model="whisper-1",
23
+ file=audio_file,temperature = 0)
24
+ st.text_area("Transcription", value=transcript_english.text)
25
+
26
+