SevaSk / ecoute

Ecoute is a live transcription tool that provides real-time transcripts for both the user's microphone input (You) and the user's speakers output (Speaker) in a textbox. It also generates a suggested response using OpenAI's GPT-3.5 for the user to say based on the live transcription of the conversation.
https://github.com/SevaSk/ecoute
MIT License
5.89k stars 827 forks source link

Resolve setup issues for macOS (Venture 13.4): pyaudiowpatch -> pyaud… #91

Open mlubbad opened 1 year ago

mlubbad commented 1 year ago

Resolve setup issues for macOS (Venture 13.4): pyaudiowpatch -> pyaudio, context manager error, host API not found, KeyError, ..etc

s0d3s commented 1 year ago

Figere unum conteram aliud

Firstly, your PR will make it impossible to use for Windows users (does not support the CoreAudio API).

Secondly, even for MacOS users, your code will not work correctly.

As far as I know, PyAudio, in its default form, cannot record audio from speakers on MacOS via CoreAudio (probably outdated). And I would recommend using the Jack API interface for this purpose.

How to fix

If you just want to avoid installation errors (rather than using this functionality), then it will be enough to wrap all pyaudiowpatch imports:

from

import pyaudiowpatch as pyaudio

to

try:
    import pyaudiowpatch as pyaudio
except ImportError:
    import pyaudio

But if you want to use the functionality of recording sound from speakers, then you need to look for a separate solution, or rewrite\modify PyAudio.

In this case, you may also have to separate the implementation for Windows and Linux\MacOS

s0d3s commented 1 year ago

I checked again, and came to the same conclusion - your code does not contribute to recording sound from the speakers. Especially on macOS using Core Audio.

Are you aware of what the code you modify is responsible for? This piece is responsible for recording sound from the speakers (what you hear). But at the moment, PyAudio does not support this functionality on macOS, especially through Core Audio. So your code shouldn't even work.

Then what did you mean when you said that everything works for you? You said that the application works well through the microphone, is it? This is how it worked before your changes.

Please answer the following questions:

I ask because your code does not contribute to either the first or the second.

s0d3s commented 1 year ago

I created a PR for your fork that adequately solves the problem in the second way(just bypass the errors).

It has been tested on both Windows and MacOS. All the nuances are described in the PR itself.

As far as I understand, you were not going to solve the problem with recording from the speakers. So I suggest that you accept my PR and we can move on to consider the merge.

mlubbad commented 1 year ago

You are right, done from my end.

I’ll try to support the right function (recording from the speaker through the microphone of the device) soon.

I’ll inform you once, I get success.

For now, I just accept and merged your PR, could we proceed?

Thanks 🌹

s0d3s commented 1 year ago

@SevaSk Hi🖐, I've made a change that solves the OP's problem: bypass startup errors on macOS..

I checked the work on Windows and macOS - *everything works. (Need someone to check too)

IMPORTANT: This is not a solution to the problem of recording sound from speakers on macOS, but only a workaround so that the application can work under this OS through a microphone. ❗ *It is also worth knowing that the speaker recording stream (on macOS) completely duplicates the microphone stream. This was the easiest way to get around the bugs without having to rewrite a big part of your code.

Not sure about the relative usefulness of this PR, but it will buy time before the problem of multi-platform speaker recording is fully resolved.

s0d3s commented 1 year ago

@mlubbad Yes, we will find out the opinion of the maintainer and probably proceed to merge.

s0d3s commented 1 year ago

It's all demagogy and endless dialogue. If you agree with my last comment, then just write what you think is necessary for this PR and I will implement it in any form you want. After all, this is your repository😉