szili2011 commited on
Commit
9b14df9
1 Parent(s): 1925476

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from gtts import gTTS
4
+ import os
5
+
6
+ # Load a text generation pipeline
7
+ generator = pipeline('text-generation', model='gpt2')
8
+
9
+ # Streamlit app
10
+ st.title("Phone-Guy-Generator")
11
+ st.subheader("Generate Custom FNaF Phone Calls")
12
+
13
+ # User inputs
14
+ night = st.selectbox("Select the Night", ["1", "2", "3", "4", "5", "6", "7"])
15
+ tone = st.selectbox("Select the Tone of the Call", ["Friendly", "Warning", "Ominous", "Neutral"])
16
+ length = st.slider("Select the Length of the Call (in words)", 50, 300, 150)
17
+ include_phrase = st.text_input("Include a Specific Phrase (Optional)")
18
+
19
+ # Generate phone call
20
+ if st.button("Generate Phone Call"):
21
+ # Construct the prompt based on user input
22
+ prompt = f"Generate Custom FNaF Phone Call for night {night}. The tone should be {tone.lower()}."
23
+ if include_phrase:
24
+ prompt += f" Make sure to include the phrase: '{include_phrase}'."
25
+
26
+ # Generate the text
27
+ result = generator(prompt, max_length=length, num_return_sequences=1)
28
+ generated_text = result[0]['generated_text']
29
+
30
+ # Display the generated phone call
31
+ st.text(generated_text)
32
+
33
+ # Convert the generated text to speech
34
+ tts = gTTS(generated_text, lang='en')
35
+ tts.save("phone_call.mp3")
36
+
37
+ # Provide a download link for the generated speech
38
+ audio_file = open("phone_call.mp3", "rb")
39
+ st.audio(audio_file.read(), format='audio/mp3')
40
+ audio_file.close()
41
+
42
+ # Optionally, remove the file after use
43
+ os.remove("phone_call.mp3")