Compare commits
No commits in common. "db61dc5329aeb99ac206f2885c6e869139457f35" and "b69dd5a800d96400fe07d382a529dd3661877be7" have entirely different histories.
db61dc5329
...
b69dd5a800
@ -64,25 +64,24 @@ class SherpaNcnnAsr(AsrBase):
|
||||
self._notify_complete('介绍中国5000年历史文学')
|
||||
segment_id += 1
|
||||
time.sleep(60)
|
||||
'''
|
||||
with sd.InputStream(channels=1, dtype="float32", samplerate=self._sample_rate) as s:
|
||||
while not self._stop_event.is_set():
|
||||
samples, _ = s.read(self._samples_per_read) # a blocking read
|
||||
samples = samples.reshape(-1)
|
||||
self._recognizer.accept_waveform(self._sample_rate, samples)
|
||||
|
||||
is_endpoint = self._recognizer.is_endpoint
|
||||
|
||||
result = self._recognizer.text
|
||||
if result and (last_result != result):
|
||||
last_result = result
|
||||
print("\r{}:{}".format(segment_id, result), end=".", flush=True)
|
||||
self._notify_process(result)
|
||||
|
||||
if is_endpoint:
|
||||
if result:
|
||||
print("\r{}:{}".format(segment_id, result), flush=True)
|
||||
self._notify_complete(result)
|
||||
segment_id += 1
|
||||
self._recognizer.reset()
|
||||
'''
|
||||
#
|
||||
# with sd.InputStream(channels=1, dtype="float32", samplerate=self._sample_rate) as s:
|
||||
# while not self._stop_event.is_set():
|
||||
# samples, _ = s.read(self._samples_per_read) # a blocking read
|
||||
# samples = samples.reshape(-1)
|
||||
# self._recognizer.accept_waveform(self._sample_rate, samples)
|
||||
#
|
||||
# is_endpoint = self._recognizer.is_endpoint
|
||||
#
|
||||
# result = self._recognizer.text
|
||||
# if result and (last_result != result):
|
||||
# last_result = result
|
||||
# print("\r{}:{}".format(segment_id, result), end=".", flush=True)
|
||||
# self._notify_process(result)
|
||||
#
|
||||
# if is_endpoint:
|
||||
# if result:
|
||||
# print("\r{}:{}".format(segment_id, result), flush=True)
|
||||
# self._notify_complete(result)
|
||||
# segment_id += 1
|
||||
# self._recognizer.reset()
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 452 KiB |
Binary file not shown.
Before Width: | Height: | Size: 114 KiB |
Binary file not shown.
Before Width: | Height: | Size: 258 KiB |
@ -1,36 +0,0 @@
|
||||
#encoding = utf8
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
from asr import SherpaNcnnAsr
|
||||
|
||||
try:
|
||||
import sounddevice as sd
|
||||
except ImportError as e:
|
||||
print("Please install sounddevice first. You can use")
|
||||
print()
|
||||
print(" pip install sounddevice")
|
||||
print()
|
||||
print("to install it")
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def main():
|
||||
print("Started! Please speak")
|
||||
asr = SherpaNcnnAsr()
|
||||
time.sleep(20)
|
||||
print("Stop! ")
|
||||
asr.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
devices = sd.query_devices()
|
||||
print(devices)
|
||||
default_input_device_idx = sd.default.device[0]
|
||||
print(f'Use default device: {devices[default_input_device_idx]["name"]}')
|
||||
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
print("\nCaught Ctrl + C. Exiting")
|
Loading…
Reference in New Issue
Block a user