-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord.py
More file actions
executable file
·50 lines (43 loc) · 1.58 KB
/
record.py
File metadata and controls
executable file
·50 lines (43 loc) · 1.58 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/python3
# Plik jest tylko w celu nagrania próbek do porównania.
from numpy import test
import sounddevice as sd
import time
import scipy.io.wavfile as wav
def recordReferenceAudio(file, duration=7, samplerate=16000):
print("Przeczytaj dwa zdania które zostaną nagrane i zapisane jako referencyjna próbka")
print("1. Nazywam się Cezary Baryka i posiadam szklany dom")
print("2. To będzie moja próbka głosu do tego systemu")
print("nagrywanie zacznie się za 3 sekundy")
time.sleep(3)
print("nagrywam...")
try:
recording = sd.rec(int(duration*samplerate),samplerate,channels=1,dtype='int16')
sd.wait()
wav.write(str(file)+".wav",samplerate,recording)
print("Nagrane!")
return
except:
print("Błąd nagrywania dźwięku")
return
def recordTestAudio(file, duration=2, samplerate=16000):
print("Przeczytaj to krótkie zdanie aby potwierdzić swoją tożsamość:")
print("Karaluchy to potężne stworzenia")
print("nagrywanie zacznie się za 3 sekundy")
time.sleep(3)
print("nagrywam...")
try:
recording = sd.rec(int(duration*samplerate),samplerate,channels=1,dtype='int16')
sd.wait()
wav.write(str(file)+".wav",samplerate,recording)
print("Nagrane!")
return
except:
print("Błąd nagrywania próbki testowej")
return
print("Podaj nazwe pod ktora zapisać plik referencyjny")
ref = str(input())
print("Podaj nazwe pod ktora zapisać plik test")
test = str(input())
recordReferenceAudio(file=ref)
recordTestAudio(file=test)