-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Integration-Automation/dev
Dev
- Loading branch information
Showing
9 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,12 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "frontengine_dev" | ||
version = "0.0.26" | ||
version = "0.0.28" | ||
authors = [ | ||
{ name = "JE-Chen", email = "[email protected]" }, | ||
] | ||
dependencies = [ | ||
"PySide6", | ||
"qt-material", | ||
"EdgeGPT" | ||
"PySide6", "qt-material", "EdgeGPT", "pyttsx3", "SpeechRecognition", "PyAudio" | ||
] | ||
description = "FrontEngine is BingGPT that can use-define front end or only use like screen saver" | ||
requires-python = ">=3.8" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import sys | ||
import time | ||
|
||
from PySide6.QtWidgets import QWidget, QPushButton, QBoxLayout, QLineEdit | ||
from speech_recognition import Microphone | ||
from speech_recognition import Recognizer | ||
from speech_recognition import RequestError, UnknownValueError | ||
from threading import Thread | ||
|
||
from frontengine.utils.multi_language.language_wrapper import language_wrapper | ||
|
||
|
||
def callback(recognizer: Recognizer, audio): | ||
try: | ||
print(recognizer.recognize_google(audio)) | ||
except (RequestError, UnknownValueError) as error: | ||
print(repr(error), file=sys.stderr) | ||
|
||
|
||
class ChatSpeechToText(QWidget): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
# Recognize | ||
self.recognizer = Recognizer() | ||
try: | ||
self.microphone = Microphone() | ||
except IOError as error: | ||
print(repr(error), file=sys.stderr) | ||
# UI | ||
self.box_layout = QBoxLayout(QBoxLayout.Direction.LeftToRight) | ||
self.voice_text_edit = QLineEdit() | ||
self.start_listen_button = QPushButton( | ||
language_wrapper.language_word_dict.get("chat_recognizer_voice_button")) | ||
self.start_listen_button.clicked.connect(self.start_listener_thread) | ||
self.send_text_button = QPushButton( | ||
language_wrapper.language_word_dict.get("chat_scene_send_chat")) | ||
self.box_layout.addWidget(self.voice_text_edit) | ||
self.box_layout.addWidget(self.start_listen_button) | ||
self.box_layout.addWidget(self.send_text_button) | ||
self.setLayout(self.box_layout) | ||
|
||
def start_listener_thread(self): | ||
listener_thread = Thread(target=self.start_listener) | ||
listener_thread.daemon = True | ||
listener_thread.start() | ||
|
||
def start_listener(self): | ||
with self.microphone as source: | ||
self.recognizer.adjust_for_ambient_noise(source, duration=0.3) | ||
stop_listening = self.recognizer.listen_in_background(self.microphone, callback) | ||
for receive_sound_time in range(50): | ||
time.sleep(0.1) | ||
stop_listening(wait_for_stop=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,12 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "frontengine" | ||
version = "0.0.25" | ||
version = "0.0.27" | ||
authors = [ | ||
{ name = "JE-Chen", email = "[email protected]" }, | ||
] | ||
dependencies = [ | ||
"PySide6", | ||
"qt-material", | ||
"EdgeGPT" | ||
"PySide6", "qt-material", "EdgeGPT", "pyttsx3", "SpeechRecognition", "PyAudio" | ||
] | ||
description = "FrontEngine is BingGPT that can use-define front end or only use like screen saver" | ||
requires-python = ">=3.8" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
PySide6 | ||
qt-material | ||
EdgeGPT | ||
pyttsx3 | ||
SpeechRecognition | ||
frontengine | ||
PyAudio |