diff --git a/py/requirements.txt b/py/requirements.txt index 7ea1a85..8c6a016 100644 --- a/py/requirements.txt +++ b/py/requirements.txt @@ -13,5 +13,4 @@ python-weather pycouchdb pyttsx3 pip-licenses -openai-whisper -pydub \ No newline at end of file +openai-whisper \ No newline at end of file diff --git a/py/voice.py b/py/voice.py index b9500da..ec6c407 100644 --- a/py/voice.py +++ b/py/voice.py @@ -1,40 +1,20 @@ import speech_recognition as sr -from pydub import AudioSegment class VoiceRecognition: - def check_audio_format(self, file_path): - try: - audio = AudioSegment.from_ogg(file_path) - print(f"Audio format: {audio.format}") - return True - except Exception as e: - print(f"Error reading audio file: {e}") - return False - - def basic_recognition(self, audio, option): + @staticmethod + def basic_recognition(audio, option): print(type(audio)) print("preparing") r = sr.Recognizer() - - # Read the data from the FileStorage object - audio_data = audio.read() - - # Write the audio data to a file - with open('output.wav', 'wb') as file: - file.write(audio_data) - - self.check_audio_format(audio) if option == "online": with sr.AudioFile(audio) as source: - print(type(source)) print("online") text = r.recognize_google_cloud(source) print("recognized as: " + text) return text elif option == "offline": with sr.AudioFile(audio) as source: - print(type(source)) print("offline") text = r.recognize_sphinx(source) print("recognized as: " + text)