-
Notifications
You must be signed in to change notification settings - Fork 837
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
added support for m1 mac #40
base: main
Are you sure you want to change the base?
Changes from 1 commit
c2108d1
08e76a3
3d13c82
c425ced
bb7a41a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import custom_speech_recognition as sr | ||
import pyaudiowpatch as pyaudio | ||
from datetime import datetime | ||
import os | ||
|
||
if os.name == 'nt': | ||
import pyaudiowpatch as pyaudio | ||
else: | ||
import pyaudio | ||
|
||
RECORD_TIMEOUT = 3 | ||
ENERGY_THRESHOLD = 1000 | ||
|
@@ -34,17 +39,20 @@ def __init__(self): | |
|
||
class DefaultSpeakerRecorder(BaseRecorder): | ||
def __init__(self): | ||
with pyaudio.PyAudio() as p: | ||
wasapi_info = p.get_host_api_info_by_type(pyaudio.paWASAPI) | ||
default_speakers = p.get_device_info_by_index(wasapi_info["defaultOutputDevice"]) | ||
|
||
if not default_speakers["isLoopbackDevice"]: | ||
for loopback in p.get_loopback_device_info_generator(): | ||
if default_speakers["name"] in loopback["name"]: | ||
default_speakers = loopback | ||
break | ||
else: | ||
print("[ERROR] No loopback device found.") | ||
if os.name == 'nt': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DefaultSpeakerRecorder should be agnostic to operating system. Same as point 1) |
||
with pyaudio.PyAudio() as p: | ||
wasapi_info = p.get_host_api_info_by_type(pyaudio.paWASAPI) | ||
default_speakers = p.get_device_info_by_index(wasapi_info["defaultOutputDevice"]) | ||
if not default_speakers["isLoopbackDevice"]: | ||
for loopback in p.get_loopback_device_info_generator(): | ||
if default_speakers["name"] in loopback["name"]: | ||
default_speakers = loopback | ||
break | ||
else: | ||
print("[ERROR] No loopback device found.") | ||
else: | ||
p = pyaudio.PyAudio() | ||
default_speakers = p.get_device_info_by_index(0) | ||
iamwille-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
source = sr.Microphone(speaker=True, | ||
device_index= default_speakers["index"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,14 @@ | |
import custom_speech_recognition as sr | ||
import io | ||
from datetime import timedelta | ||
import pyaudiowpatch as pyaudio | ||
from heapq import merge | ||
|
||
if os.name == 'nt': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as 1) |
||
import pyaudiowpatch as pyaudio | ||
else: | ||
import pyaudio | ||
|
||
|
||
PHRASE_TIMEOUT = 3.05 | ||
|
||
MAX_PHRASES = 10 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,10 @@ def get_pyaudio(): | |
Imports the pyaudio module and checks its version. Throws exceptions if pyaudio can't be found or a wrong version is installed | ||
""" | ||
try: | ||
import pyaudiowpatch as pyaudio | ||
if os.name == 'nt': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import pyaudiowpatch as pyaudio | ||
else: | ||
import pyaudio | ||
except ImportError: | ||
raise AttributeError("Could not find PyAudio; check installation") | ||
from distutils.version import LooseVersion | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.