Update app.py
Browse files
app.py
CHANGED
|
@@ -1898,39 +1898,42 @@ filename = save_and_play_audio(audio_recorder)
|
|
| 1898 |
if filename is not None: # whisper1
|
| 1899 |
try:
|
| 1900 |
transcript = transcribe_audio(filename, "whisper-1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1901 |
except:
|
| 1902 |
st.write(' ')
|
| 1903 |
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
| 1904 |
filename = None
|
| 1905 |
-
|
| 1906 |
-
#if filename is not None:
|
| 1907 |
-
# transcript=''
|
| 1908 |
-
#transcript=transcribe_whisperLTurbo(filename)
|
| 1909 |
-
#transcript=transcribe_canary(filename)
|
| 1910 |
-
# transcript=process_audio(filename)
|
| 1911 |
-
|
| 1912 |
-
# Search ArXiV and get the Summary and Reference Papers Listing
|
| 1913 |
-
result = search_arxiv(transcript)
|
| 1914 |
-
|
| 1915 |
-
# Start chatbot with transcript:
|
| 1916 |
|
| 1917 |
-
# ChatBot Entry
|
| 1918 |
MODEL = "gpt-4o-2024-05-13"
|
| 1919 |
openai.api_key = os.getenv('OPENAI_API_KEY')
|
| 1920 |
openai.organization = os.getenv('OPENAI_ORG_ID')
|
| 1921 |
client = OpenAI(api_key= os.getenv('OPENAI_API_KEY'), organization=os.getenv('OPENAI_ORG_ID'))
|
|
|
|
| 1922 |
st.session_state.messages.append({"role": "user", "content": transcript})
|
|
|
|
| 1923 |
with st.chat_message("user"):
|
| 1924 |
st.markdown(transcript)
|
|
|
|
| 1925 |
with st.chat_message("assistant"):
|
| 1926 |
completion = client.chat.completions.create(
|
| 1927 |
model=MODEL,
|
| 1928 |
messages = st.session_state.messages,
|
| 1929 |
stream=True
|
| 1930 |
)
|
|
|
|
| 1931 |
response = process_text2(text_input=prompt)
|
|
|
|
| 1932 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 1933 |
|
|
|
|
| 1934 |
# Scholary ArXiV Search ------------------------- !!
|
| 1935 |
session_state = {}
|
| 1936 |
if "search_queries" not in session_state:
|
|
|
|
| 1898 |
if filename is not None: # whisper1
|
| 1899 |
try:
|
| 1900 |
transcript = transcribe_audio(filename, "whisper-1")
|
| 1901 |
+
st.markdown(transcript)
|
| 1902 |
+
result = search_arxiv(transcript)
|
| 1903 |
+
with st.chat_message("user"):
|
| 1904 |
+
st.markdown(transcript
|
| 1905 |
+
st.session_state.messages.append({"role": "user", "content": transcript})
|
| 1906 |
+
with st.chat_message("assistant"):
|
| 1907 |
+
st.markdown(result)
|
| 1908 |
+
st.session_state.messages.append({"role": "assistant", "content": result})
|
| 1909 |
except:
|
| 1910 |
st.write(' ')
|
| 1911 |
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
| 1912 |
filename = None
|
| 1913 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1914 |
|
|
|
|
| 1915 |
MODEL = "gpt-4o-2024-05-13"
|
| 1916 |
openai.api_key = os.getenv('OPENAI_API_KEY')
|
| 1917 |
openai.organization = os.getenv('OPENAI_ORG_ID')
|
| 1918 |
client = OpenAI(api_key= os.getenv('OPENAI_API_KEY'), organization=os.getenv('OPENAI_ORG_ID'))
|
| 1919 |
+
|
| 1920 |
st.session_state.messages.append({"role": "user", "content": transcript})
|
| 1921 |
+
|
| 1922 |
with st.chat_message("user"):
|
| 1923 |
st.markdown(transcript)
|
| 1924 |
+
|
| 1925 |
with st.chat_message("assistant"):
|
| 1926 |
completion = client.chat.completions.create(
|
| 1927 |
model=MODEL,
|
| 1928 |
messages = st.session_state.messages,
|
| 1929 |
stream=True
|
| 1930 |
)
|
| 1931 |
+
|
| 1932 |
response = process_text2(text_input=prompt)
|
| 1933 |
+
|
| 1934 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 1935 |
|
| 1936 |
+
|
| 1937 |
# Scholary ArXiV Search ------------------------- !!
|
| 1938 |
session_state = {}
|
| 1939 |
if "search_queries" not in session_state:
|