Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ from langchain.llms import OpenAI
|
|
| 12 |
from langchain.memory import ConversationBufferMemory
|
| 13 |
import streamlit as st
|
| 14 |
import os
|
|
|
|
| 15 |
|
| 16 |
def db(texts,text_splitter,api):
|
| 17 |
|
|
@@ -40,7 +41,7 @@ def main():
|
|
| 40 |
placeholder.empty()
|
| 41 |
placeholder.title("your openai api key")
|
| 42 |
global api
|
| 43 |
-
api=st.text_input("enter
|
| 44 |
if st.button("Load API Key"):
|
| 45 |
# Set the environment variable with the provided API key
|
| 46 |
set_environment_variable(api)
|
|
@@ -72,6 +73,14 @@ def main():
|
|
| 72 |
output = ai(query)
|
| 73 |
chat_history=chat_history.append(query)
|
| 74 |
st.write(output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
elif page == 'Random talk':
|
| 77 |
chat_history=[]
|
|
@@ -85,6 +94,12 @@ def main():
|
|
| 85 |
# Parse the response to get the response text for our prompt
|
| 86 |
response_text = openai_response.choices[0].text
|
| 87 |
st.write( response_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
|
|
|
| 12 |
from langchain.memory import ConversationBufferMemory
|
| 13 |
import streamlit as st
|
| 14 |
import os
|
| 15 |
+
from elevenlabs import generate
|
| 16 |
|
| 17 |
def db(texts,text_splitter,api):
|
| 18 |
|
|
|
|
| 41 |
placeholder.empty()
|
| 42 |
placeholder.title("your openai api key")
|
| 43 |
global api
|
| 44 |
+
api=st.text_input("enter here")
|
| 45 |
if st.button("Load API Key"):
|
| 46 |
# Set the environment variable with the provided API key
|
| 47 |
set_environment_variable(api)
|
|
|
|
| 73 |
output = ai(query)
|
| 74 |
chat_history=chat_history.append(query)
|
| 75 |
st.write(output)
|
| 76 |
+
# set_api_key("<YOUR_API_KEY>") # Check the guide on how to get a free API key: https://docs.elevenlabs.io/authentication/01-xi-api-key
|
| 77 |
+
XI_API_KEY = "<xi-api-key>"
|
| 78 |
+
audio = generate(
|
| 79 |
+
text=output,
|
| 80 |
+
voice="Bella"
|
| 81 |
+
)
|
| 82 |
+
st.audio(audio)
|
| 83 |
+
|
| 84 |
|
| 85 |
elif page == 'Random talk':
|
| 86 |
chat_history=[]
|
|
|
|
| 94 |
# Parse the response to get the response text for our prompt
|
| 95 |
response_text = openai_response.choices[0].text
|
| 96 |
st.write( response_text)
|
| 97 |
+
XI_API_KEY = "<xi-api-key>"
|
| 98 |
+
audio = generate(
|
| 99 |
+
text=response_text,
|
| 100 |
+
voice="Bella"
|
| 101 |
+
)
|
| 102 |
+
st.audio(audio)
|
| 103 |
|
| 104 |
|
| 105 |
if __name__ == "__main__":
|