Spaces:
Runtime error
Runtime error
Commit ·
2e43964
1
Parent(s): ffae8ce
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import openai
|
|
| 3 |
import streamlit as st
|
| 4 |
import speech_recognition as sr
|
| 5 |
import pyttsx3
|
|
|
|
|
|
|
| 6 |
|
| 7 |
openai.api_key = "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"
|
| 8 |
r = sr.Recognizer()
|
|
@@ -18,14 +20,24 @@ def text_input():
|
|
| 18 |
prompt = st.text_input("HEY THERE! LET ME KNOW WHAT YOU WANT ")
|
| 19 |
return prompt
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def voice_input():
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
return text
|
| 28 |
|
|
|
|
| 29 |
def text_to_speech(text):
|
| 30 |
engine = pyttsx3.init()
|
| 31 |
engine.say(text)
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
import speech_recognition as sr
|
| 5 |
import pyttsx3
|
| 6 |
+
import sounddevice as sd
|
| 7 |
+
import numpy as np
|
| 8 |
|
| 9 |
openai.api_key = "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"
|
| 10 |
r = sr.Recognizer()
|
|
|
|
| 20 |
prompt = st.text_input("HEY THERE! LET ME KNOW WHAT YOU WANT ")
|
| 21 |
return prompt
|
| 22 |
|
| 23 |
+
import sounddevice as sd
|
| 24 |
+
import numpy as np
|
| 25 |
+
import speech_recognition as sr
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# Replace voice_input function
|
| 29 |
def voice_input():
|
| 30 |
+
st.write("Speak now!")
|
| 31 |
+
# Record audio for 5 seconds
|
| 32 |
+
duration = 5
|
| 33 |
+
sample_rate = 16000
|
| 34 |
+
audio = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=1)
|
| 35 |
+
sd.wait()
|
| 36 |
+
# Convert audio to text
|
| 37 |
+
text = r.recognize_google(audio.flatten(), language="en-US").lower()
|
| 38 |
return text
|
| 39 |
|
| 40 |
+
|
| 41 |
def text_to_speech(text):
|
| 42 |
engine = pyttsx3.init()
|
| 43 |
engine.say(text)
|