MedQuery-Assist / audio_handler.py
twissamodi's picture
retrieve and store using user id
9409f90
raw
history blame contribute delete
806 Bytes
from transformers import pipeline
class AudioHandler:
def __init__(self):
self.transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-small")
def transcribe_audio(self, audio, current_text, file_input, message_history, user_state, session_state, chat_func):
if audio is None:
return message_history, current_text, None, file_input, user_state, session_state
transcript = self.transcriber(audio)["text"].strip()
updated_history, cleared_text, cleared_file, user_state, session_state = chat_func(
transcript,
file_input,
message_history,
user_state,
session_state
)
return updated_history, cleared_text, None, cleared_file