-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmaster_mode_manager.py
25 lines (19 loc) · 959 Bytes
/
master_mode_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# uses speechbrain to analyze master voice
# author: @omegaui
# github: https://github.com/omegaui/linux-voice-control
# license: GNU GPL v3
import os.path
from speechbrain.pretrained import SpeakerRecognition
# @return True if master-mode configuration is ready
def canEnableMasterMode():
return os.path.exists('training-data/master-mode')
# uses speechbrain to check if the current mic fetched audio is same as the master mode sample audio
def isMasterSpeaking():
verification = SpeakerRecognition.from_hparams(source="speechbrain/spkrec-ecapa-voxceleb",
savedir="pretrained_models/spkrec-ecapa-voxceleb")
for i in range(1, 4):
score, prediction = verification.verify_files(f"training-data/master_mode_audio_sample{i}.wav",
"misc/last-mic-fetch.wav")
if not not prediction[0]:
return True
return False