streamlit-gpt2 / app.py
vakodiya's picture
Audio question and audio response
73866b8
raw
history blame
740 Bytes
import streamlit as st
import os
from generate_answer import generate_answer
from audio_to_text import audio_to_text
from text_to_audio import text_to_audio
file_path_relative = 'SDLC.wav'
file_path_abs = os.path.abspath(file_path_relative)
st.title("GPT 2 Chat Bot?")
input_text = st.text_area("Search query:")
if st.button("""Enter >>>>> """):
if input_text:
response_text = generate_answer(input_text)
st.write(response_text)
st.audio(data=file_path_abs, format='audio/wav')
if st.button("""Use Audio question """):
audio_text = audio_to_text(file_path_abs)
answer = generate_answer(audio_text)
audio_bytes = text_to_audio(answer)
st.audio(audio_bytes, format="audio/wav")
st.write(answer)