Spaces:
Sleeping
Sleeping
N.Achyuth Reddy
commited on
Commit
·
2dfe1eb
1
Parent(s):
f66e095
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,40 @@ def transcribe(wav_path):
|
|
37 |
api_name="/predict"
|
38 |
)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
# Streamlit UI
|
42 |
st.title(TITLE)
|
@@ -90,37 +124,3 @@ if prompt := textinput:
|
|
90 |
st.markdown(response)
|
91 |
# Add assistant response to chat history
|
92 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
93 |
-
|
94 |
-
def text_to_speech(text, language='en', filename='output.mp3'):
|
95 |
-
# Create a gTTS object
|
96 |
-
tts = gTTS(text=text, lang=language, slow=False)
|
97 |
-
|
98 |
-
# Save the audio file
|
99 |
-
tts.save(filename)
|
100 |
-
|
101 |
-
# Play the audio file
|
102 |
-
os.system(f'start {filename}') # This works on Windows. For other OS, you might need a different command.
|
103 |
-
|
104 |
-
|
105 |
-
# Prediction function
|
106 |
-
def predict(message, system_prompt='Your name is OpenGPT. You are developed by Achyuth. You need to mostly focus on giving information about future agriculture and advanced farming. Empower yourself farming future with cutting-edge technology and sustainable practices. You need to cultivate a greener and more productive. Your developer is studying in The Hyderabad Public School Kadapa.', temperature=0.7, max_new_tokens=4096,Topp=0.5,Repetitionpenalty=1.2):
|
107 |
-
with st.status("Starting client"):
|
108 |
-
client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
|
109 |
-
st.write("Requesting Audio Transcriber")
|
110 |
-
with st.status("Requesting AgriTure v1"):
|
111 |
-
st.write("Requesting API")
|
112 |
-
response = client.predict(
|
113 |
-
message, # str in 'Message' Textbox component
|
114 |
-
system_prompt, # str in 'Optional system prompt' Textbox component
|
115 |
-
max_new_tokens, # int | float (numeric value between 0 and 4096)
|
116 |
-
temperature, # int | float (numeric value between 0.0 and 1.0)
|
117 |
-
Topp,
|
118 |
-
500,
|
119 |
-
Repetitionpenalty, # int | float (numeric value between 1.0 and 2.0)
|
120 |
-
api_name="/chat"
|
121 |
-
)
|
122 |
-
st.write("Done")
|
123 |
-
return response
|
124 |
-
|
125 |
-
# Example usage
|
126 |
-
text_to_speech(response)
|
|
|
37 |
api_name="/predict"
|
38 |
)
|
39 |
|
40 |
+
# Prediction function
|
41 |
+
def predict(message, system_prompt='Your name is OpenGPT. You are developed by Achyuth. You need to mostly focus on giving information about future agriculture and advanced farming. Empower yourself farming future with cutting-edge technology and sustainable practices. You need to cultivate a greener and more productive. Your developer is studying in The Hyderabad Public School Kadapa.', temperature=0.7, max_new_tokens=4096,Topp=0.5,Repetitionpenalty=1.2):
|
42 |
+
with st.status("Starting client"):
|
43 |
+
client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
|
44 |
+
st.write("Requesting Audio Transcriber")
|
45 |
+
with st.status("Requesting AgriTure v1"):
|
46 |
+
st.write("Requesting API")
|
47 |
+
response = client.predict(
|
48 |
+
message, # str in 'Message' Textbox component
|
49 |
+
system_prompt, # str in 'Optional system prompt' Textbox component
|
50 |
+
max_new_tokens, # int | float (numeric value between 0 and 4096)
|
51 |
+
temperature, # int | float (numeric value between 0.0 and 1.0)
|
52 |
+
Topp,
|
53 |
+
500,
|
54 |
+
Repetitionpenalty, # int | float (numeric value between 1.0 and 2.0)
|
55 |
+
api_name="/chat"
|
56 |
+
)
|
57 |
+
st.write("Done")
|
58 |
+
return response
|
59 |
+
|
60 |
+
def text_to_speech(text, language='en', filename='output.mp3'):
|
61 |
+
# Create a gTTS object
|
62 |
+
tts = gTTS(text=text, lang=language, slow=False)
|
63 |
+
|
64 |
+
# Save the audio file
|
65 |
+
tts.save(filename)
|
66 |
+
|
67 |
+
# Play the audio file
|
68 |
+
os.system(f'start {filename}') # This works on Windows. For other OS, you might need a different command.
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
# Example usage
|
73 |
+
text_to_speech(response)
|
74 |
|
75 |
# Streamlit UI
|
76 |
st.title(TITLE)
|
|
|
124 |
st.markdown(response)
|
125 |
# Add assistant response to chat history
|
126 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|