-
Notifications
You must be signed in to change notification settings - Fork 780
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 all commits
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(1) | ||
|
||
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 |
---|---|---|
|
@@ -20,6 +20,11 @@ Follow these steps to set up and run Ecoute on your local machine. | |
- Windows OS (Not tested on others) | ||
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. We can add M1 macs here too :) |
||
- FFmpeg | ||
|
||
|
||
|
||
|
||
<details> | ||
<summary>Windows</summary> | ||
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. Nice! |
||
If FFmpeg is not installed in your system, you can follow the steps below to install it. | ||
|
||
First, you need to install Chocolatey, a package manager for Windows. Open your PowerShell as Administrator and run the following command: | ||
|
@@ -31,6 +36,20 @@ Once Chocolatey is installed, you can install FFmpeg by running the following co | |
choco install ffmpeg-full | ||
``` | ||
Please ensure that you run these commands in a PowerShell window with administrator privileges. If you face any issues during the installation, you can visit the official Chocolatey and FFmpeg websites for troubleshooting. | ||
</details> | ||
|
||
<details> | ||
<summary>macOS</summary> | ||
If FFmpeg is not installed in your system, you can follow the steps below to install it. | ||
|
||
brew install ffmpeg | ||
brew install portaudio | ||
brew install python-tk | ||
|
||
You might need to change the index of your speaker depending on your setting to 0 or 1 | ||
on line 55 AudioRecorder.py | ||
|
||
</details> | ||
|
||
### 🔧 Installation | ||
|
||
|
@@ -67,6 +86,7 @@ Please ensure that you run these commands in a PowerShell window with administra | |
``` | ||
Replace "API KEY" with your actual OpenAI API key. Save this file as keys.py within the ecoute directory. | ||
|
||
|
||
### 🎬 Running Ecoute | ||
|
||
Run the main script: | ||
|
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.