add sales transcrip
This commit is contained in:
parent
a7511e15ac
commit
b6eccf4194
53
main3.py
Normal file
53
main3.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
from speechlib import Transcriptor
|
||||||
|
from configparser import ConfigParser
|
||||||
|
import os
|
||||||
|
import streamlit as st
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
|
||||||
|
|
||||||
|
def str2bool(v):
|
||||||
|
return v.lower() in ("yes", "true", "t", "1")
|
||||||
|
|
||||||
|
config = ConfigParser()
|
||||||
|
config.read('config.ini')
|
||||||
|
audiofolder = config.get('FILE', 'audiofolder')
|
||||||
|
access_token = config.get('FILE', 'accesstoken')
|
||||||
|
voicefolder = config.get('FILE', 'voicefolder')
|
||||||
|
outputfolder2 = config.get('FILE', 'outputfolder2')
|
||||||
|
language = "id"
|
||||||
|
quantization = str2bool(config.get('FILE', 'quantization'))
|
||||||
|
modelSize = "medium"
|
||||||
|
|
||||||
|
st.title("Sales Transcription")
|
||||||
|
|
||||||
|
audio = st.file_uploader("Upload audio file (.mp3/.wav/.m4a)", type=["mp3", "wav", "m4a"])
|
||||||
|
crew_id = st.text_input("Sales ID")
|
||||||
|
crew_name = st.text_input("Sales Name")
|
||||||
|
customer_name = st.text_input("Customer Name")
|
||||||
|
date = st.date_input("Date")
|
||||||
|
if st.button("Transcribe"):
|
||||||
|
if audio is not None and crew_id:
|
||||||
|
with st.spinner("Transcribing..."):
|
||||||
|
# Save the uploaded audio file to a temporary location
|
||||||
|
file_details = {"filename": audio.name, "filetype": audio.type, "filesize": audio.size}
|
||||||
|
print(file_details)
|
||||||
|
|
||||||
|
temp_dir = tempfile.mkdtemp()
|
||||||
|
path = os.path.join(temp_dir, audio.name)
|
||||||
|
|
||||||
|
with open(path, "wb") as f:
|
||||||
|
f.write(audio.getvalue())
|
||||||
|
print(f"Temporary file saved at: {path}")
|
||||||
|
|
||||||
|
#audiofilewithoutextension = path.split(".mp3")[0].split(".wav")[0].split(".m4a")[0]
|
||||||
|
#filepath = os.path.join(outputfolder, os.path.basename(audiofilewithoutextension).split('/')[-1]+".txt")
|
||||||
|
filepath = os.path.join(outputfolder2, f"{crew_id}-{crew_name}-{customer_name}-{date}-Transkrip.txt")
|
||||||
|
print(f"Output file: {filepath}")
|
||||||
|
filename = open(filepath, "w")
|
||||||
|
|
||||||
|
### transcribe ###
|
||||||
|
transcriptor = Transcriptor(path, filepath, language, modelSize, access_token, voicefolder, quantization)
|
||||||
|
res = transcriptor.faster_whisper()
|
||||||
|
print(f"Content has been written to {filepath}")
|
||||||
|
st.success(f"Transcribe successful!")
|
||||||
Loading…
Reference in New Issue
Block a user