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

changed to audio device name instead of indexnumber #105

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
12 changes: 7 additions & 5 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ INGAME_PUSH_TO_TALK_KEY=

### AUDIO DEVICE IDS ###

# run src/modules/get_audio_device_ids.py in order to obtain the id for your audio devices
# run src/modules/get_audio_device_ids.py in order to obtain the name for your audio devices
# only the first one needs to be changed if you correctly setup the banana and cable software

# The mic you will be speaking into
MICROPHONE_ID=
MICROPHONE_INPUT_NAME=Microphone (usb mic

# VoiceMeeter Input (VB-Audio VoiceMeeter VAIO)
# Plays Text-to-Speech audio into your speakers/headphones for you to hear
VOICEMEETER_INPUT_ID=
VOICEMEETER_INPUT_NAME=VoiceMeeter Input (VB-Audio

# CABLE Input (VB-Audio Virtual Cable)
# Plays Text-to-Speech audio into the mic input of your application
CABLE_INPUT_ID=
CABLE_INPUT_NAME=CABLE Input (VB-Audio Virtual C

# VoiceMeeter Aux Output (VB-Audio VoiceMeeter AUX VAIO)
# Where your application audio (voice-chat) will play from
AUX_OUTPUT_ID=
AUX_OUTPUT_NAME=VoiceMeeter Aux Output (VB-Audi



### VOICEVOX SETTINGS ###
Expand Down
16 changes: 15 additions & 1 deletion src/modules/audio_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,21 @@

from .asr import speech_to_text

APP_OUTPUT_ID = int(getenv('AUX_OUTPUT_ID'))

APP_OUTPUT_NAME = getenv('AUX_OUTPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'AUX_OUTPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'AUX_OUTPUT not found starting with: {starting_name}')
APP_OUTPUT_ID = get_mic_index(APP_OUTPUT_NAME)






RECORD_TIMEOUT = int(getenv('RECORD_TIMEOUT'))
PHRASE_TIMEOUT = int(getenv('PHRASE_TIMEOUT'))
INPUT_LANGUAGE = getenv('TARGET_LANGUAGE_CODE')
Expand Down
25 changes: 23 additions & 2 deletions src/modules/thorsten.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import speech_recognition as sr

from os import getenv
from pathlib import Path
from threading import Thread
Expand All @@ -9,9 +11,28 @@

load_dotenv()




# Audio devices
SPEAKERS_INPUT_ID = int(getenv('VOICEMEETER_INPUT_ID'))
APP_INPUT_ID = int(getenv('CABLE_INPUT_ID'))
MIC_NAME = getenv('VOICEMEETER_INPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'VOICEMEETER_INPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'VOICEMEETER_INPUT not found starting with: {starting_name}')
SPEAKERS_INPUT_ID = get_mic_index(MIC_NAME)

MIC_NAME = getenv('CABLE_INPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'CABLE_INPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'CABLE_INPUT not found starting with: {starting_name}')
APP_INPUT_ID = get_mic_index(MIC_NAME)



# Voicevox settings
Expand Down
26 changes: 24 additions & 2 deletions src/modules/voicevox.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import speech_recognition as sr

from os import getenv
from pathlib import Path
from threading import Thread
Expand All @@ -10,9 +12,29 @@

load_dotenv()




# Audio devices
SPEAKERS_INPUT_ID = int(getenv('VOICEMEETER_INPUT_ID'))
APP_INPUT_ID = int(getenv('CABLE_INPUT_ID'))
MIC_NAME = getenv('VOICEMEETER_INPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'VOICEMEETER_INPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'VOICEMEETER_INPUT not found starting with: {starting_name}')
SPEAKERS_INPUT_ID = get_mic_index(MIC_NAME)

MIC_NAME = getenv('CABLE_INPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'CABLE_INPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'CABLE_INPUT not found starting with: {starting_name}')
APP_INPUT_ID = get_mic_index(MIC_NAME)



# Voicevox settings
BASE_URL = getenv('VOICEVOX_BASE_URL')
Expand Down
25 changes: 24 additions & 1 deletion src/voice_translator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import speech_recognition as sr

import wave
from os import getenv
from pathlib import Path
Expand All @@ -18,7 +20,28 @@
USE_DEEPL = getenv('USE_DEEPL', 'False').lower() in ('true', '1', 't')
DEEPL_AUTH_KEY = getenv('DEEPL_AUTH_KEY')
TARGET_LANGUAGE = getenv('TARGET_LANGUAGE_CODE')
MIC_ID = int(getenv('MICROPHONE_ID'))

MIC_NAME = getenv('MICROPHONE_INPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'MICROPHONE_INPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'MICROPHONE_INPUT not found starting with: {starting_name}')
MIC_ID = get_mic_index(MIC_NAME)

#just to check if it's found i have no clue what i'm doing
APP_OUTPUT_NAME = getenv('AUX_OUTPUT_NAME')
def get_mic_index(starting_name):
for i, microphone_name in enumerate(sr.Microphone.list_microphone_names()):
if microphone_name.startswith(starting_name):
print(f'AUX_OUTPUT found: {microphone_name} at index {i}')
return i
raise ValueError(f'AUX_OUTPUT not found starting with: {starting_name}')
APP_OUTPUT_ID = get_mic_index(APP_OUTPUT_NAME)



RECORD_KEY = getenv('MIC_RECORD_KEY')
LOGGING = getenv('LOGGING', 'False').lower() in ('true', '1', 't')
MIC_AUDIO_PATH = Path(__file__).resolve().parent / r'audio/mic.wav'
Expand Down