forked from robotics-4-all/tektrain-robot-sw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_microphone.py
50 lines (38 loc) · 1.28 KB
/
test_microphone.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
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
import unittest
import time
from pidevices.sensors.microphone import Microphone
dev_name = "dsnoop:CARD=ArrayUAC10,DEV=0"
channels = 6
framerate = 16000
class TestMicrophone(unittest.TestCase):
def test_one(self):
mic = Microphone(dev_name=dev_name, channels=channels)
audio = mic.read(secs=5, framerate=framerate, volume=100,
file_path="test.wav", file_flag=True)
def test_multi(self):
mic = Microphone()
mic.async_read(file_path='test_one.wav', secs=4, volume=100)
time.sleep(3)
mic.read(file_path='test_two.wav', secs=2, volume=100)
# Test if it is paused
mic.async_read(file_path='test_one_p.wav', secs=4, volume=100)
time.sleep(2)
mic.pause()
print("Pause")
time.sleep(1)
mic.read(file_path='test_two.wav', secs=2, volume=100)
def test_pause(self):
mic = Microphone()
mic.async_read(file_path='test.wav', secs=6, volume=100)
time.sleep(2)
mic.pause()
print("Pause")
time.sleep(1)
print("Restart")
mic.pause(False)
time.sleep(6)
def test_path(self):
mic = Microphone()
mic._fix_path('f')
if __name__ == "__main__":
unittest.main()