Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add suport for changing microphone index #263

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ whisper_type = faster_whisper
; Examples: http://127.0.0.1:8080/inference (default) / http://127.0.0.1:8070/inference (if you use the optional --port 8070 comand line argument), https://api.openai.com/v1/audio/transcriptions (if using OpenAI API)
whisper_url = http://127.0.0.1:8080/inference

; Microphone index
; Choose what mic to use.
mic_index = 100

[LanguageModel.Advanced]
; llm_api
Expand Down
1 change: 1 addition & 0 deletions src/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def run_config_editor():
self.listen_timeout = int(config['Microphone.Advanced']['listen_timeout'])
self.whisper_type = config['Microphone.Advanced']['whisper_type']
self.whisper_url = config['Microphone.Advanced']['whisper_url']
self.mic_index = int(config['Microphone.Advanced']['mic_index'])

#self.hotkey = config['Hotkey']['hotkey']
#self.textbox_timer = config['Hotkey']['textbox_timer']
Expand Down
6 changes: 5 additions & 1 deletion src/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, game_state_manager, config, api_key: str):
self.game_state_manager = game_state_manager
self.game_path = config.game_path
self.mic_enabled = config.mic_enabled
self.mic_index = config.mic_index
self.language = config.stt_language
self.task = "transcribe"
if config.stt_translate == 1:
Expand All @@ -39,7 +40,10 @@ def __init__(self, game_state_manager, config, api_key: str):
if self.mic_enabled == '1':
self.recognizer = sr.Recognizer()
self.recognizer.pause_threshold = config.pause_threshold
self.microphone = sr.Microphone()
if self.mic_index != 100:
self.microphone = sr.Microphone(device_index=self.mic_index)
else:
self.microphone = sr.Microphone()

if self.audio_threshold == 'auto':
logging.log(self.loglevel, f"Audio threshold set to 'auto'. Adjusting microphone for ambient noise...")
Expand Down