Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,15 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
from gtts import gTTS
|
4 |
import os
|
5 |
-
|
6 |
# Set your OpenAI API key
|
7 |
openai.api_key = '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' # Replace with your actual OpenAI API key
|
8 |
|
|
|
|
|
|
|
9 |
# Function to generate Trump-like response using OpenAI's GPT-3.5 or GPT-4
|
10 |
def generate_response(prompt):
|
11 |
# Craft the prompt to instruct the model to respond in a Trump-like manner
|
@@ -30,6 +34,27 @@ def generate_audio(text):
|
|
30 |
tts.save(audio_path)
|
31 |
return audio_path
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Streamlit app UI
|
34 |
st.title("Trump-like Text-to-Speech Assistant")
|
35 |
st.write("Type a question or statement, and receive a 'Trump-style' audio response!")
|
|
|
1 |
+
|
2 |
+
|
3 |
import streamlit as st
|
4 |
import openai
|
5 |
from gtts import gTTS
|
6 |
import os
|
|
|
7 |
# Set your OpenAI API key
|
8 |
openai.api_key = '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' # Replace with your actual OpenAI API key
|
9 |
|
10 |
+
# Set your OpenAI API key
|
11 |
+
openai.api_key = 'your_openai_api_key' # Replace with your actual OpenAI API key
|
12 |
+
|
13 |
# Function to generate Trump-like response using OpenAI's GPT-3.5 or GPT-4
|
14 |
def generate_response(prompt):
|
15 |
# Craft the prompt to instruct the model to respond in a Trump-like manner
|
|
|
34 |
tts.save(audio_path)
|
35 |
return audio_path
|
36 |
|
37 |
+
# Streamlit app UI
|
38 |
+
st.title("Trump-like ChatGPT")
|
39 |
+
st.write("Type in a question or statement, and receive a 'Trump-style' response in text and audio!")
|
40 |
+
|
41 |
+
# Text input from user
|
42 |
+
user_input = st.text_input("Your message:", "Enter a message here")
|
43 |
+
|
44 |
+
if user_input:
|
45 |
+
# Generate Trump-like response
|
46 |
+
trump_response = generate_response(user_input)
|
47 |
+
st.write("Trump-like Assistant:", trump_response)
|
48 |
+
|
49 |
+
# Convert response to audio
|
50 |
+
audio_output_path = generate_audio(trump_response)
|
51 |
+
audio_file = open(audio_output_path, "rb")
|
52 |
+
audio_bytes = audio_file.read()
|
53 |
+
|
54 |
+
# Display audio output
|
55 |
+
st.audio(audio_bytes, format="audio/mp3") tts.save(audio_path)
|
56 |
+
return audio_path
|
57 |
+
|
58 |
# Streamlit app UI
|
59 |
st.title("Trump-like Text-to-Speech Assistant")
|
60 |
st.write("Type a question or statement, and receive a 'Trump-style' audio response!")
|