diff --git a/AudioRecorder.py b/AudioRecorder.py
index 8c09227..a978dea 100644
--- a/AudioRecorder.py
+++ b/AudioRecorder.py
@@ -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
@@ -38,17 +43,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':
+ 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"],
diff --git a/AudioTranscriber.py b/AudioTranscriber.py
index b37eae8..7a33ac7 100644
--- a/AudioTranscriber.py
+++ b/AudioTranscriber.py
@@ -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':
+ import pyaudiowpatch as pyaudio
+else:
+ import pyaudio
+
+
PHRASE_TIMEOUT = 3.05
MAX_PHRASES = 10
diff --git a/README.md b/README.md
index e7eaa6c..ac477a3 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,11 @@ Follow these steps to set up and run Ecoute on your local machine.
- Windows OS (Not tested on others)
- FFmpeg
+
+
+
+
+Windows
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
```
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.
+
+
+
+macOS
+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
+
+
### 🔧 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:
diff --git a/custom_speech_recognition/__init__.py b/custom_speech_recognition/__init__.py
index 1d339b0..071b632 100644
--- a/custom_speech_recognition/__init__.py
+++ b/custom_speech_recognition/__init__.py
@@ -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':
+ import pyaudiowpatch as pyaudio
+ else:
+ import pyaudio
except ImportError:
raise AttributeError("Could not find PyAudio; check installation")
from distutils.version import LooseVersion
diff --git a/requirements.txt b/requirements.txt
index 78f1554..f89edf1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,9 @@ openai-whisper==20230314
Wave==0.0.2
openai==0.27.6
customtkinter==5.1.3
-PyAudioWPatch==0.2.12.5
--extra-index-url https://download.pytorch.org/whl/cu117
-torch
\ No newline at end of file
+torch
+
+# Windows-specific dependencies
+PyAudioWPatch==0.2.12.5; platform_system == "Windows"
+pyaudio; platform_system != "Windows"
\ No newline at end of file