Skip to content
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

MacOS Adaptation: Switched from PyAudioWPatch to PyAudio #164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mahmoudz
Copy link

@Mahmoudz Mahmoudz commented Jan 9, 2024

Refined for Core Audio, this update discontinues Windows compatibility. The changes include using PyAudio instead of PyAudioWPatch for audio integration. Please note that this adaptation is exclusively for macOS and may not work on Windows.

E

Warning: Discontinued Windows Compatibility

With my limited 30 minute timeframe, I prioritized adapting this awesome tool for my macOS.
However, merging these alterations into the main branch will jeopardize Windows compatibility.
To guarantee compatibility for both macOS and Windows, additional modifications are essential yet easy to be done.
Lastly, it is recommended to maintain these adjustments separate from the main branch until a comprehensive solution can ensure a seamless experience for all users.

… Core Audio, Discontinued Windows Compatibility
@flobraeuer
Copy link

flobraeuer commented Jan 9, 2024

Thanks @Mahmoudz for your work. At the very same moment, I am also trying to get it up and running on my Mac.

Did you check out the other PR from @enemaliwilliam? Here is the issue discussion #10 (comment) and here is another discussion in his PR #40 and his branch https://github.com/enemaliwilliam/ecoute/tree/add-mac-os-support? There is also @clevertang who tried it https://github.com/clevertang/ecoute/tree/mac_only

I currently review your version and try to get it running. The problem I face is that the DefaultMicRecorder ("You") and the DefaultSpeakerRecorder ("Speaker") get the same audio "duplicated", even when I use my Airpods. So I tried to change AudioRecorder.py:45 to source = sr.Microphone(device_index=1). Here is my code change in its context:

class DefaultSpeakerRecorder(BaseRecorder):
    def __init__(self):
        p = pyaudio.PyAudio()
        try:
            # Use the default input device as the audio source
            self.list_all_speakers(p)
            default_device_index = p.get_default_input_device_info()["index"]
            source = sr.Microphone(device_index=1) #default_device_index)
            super().__init__(source=source, source_name="Speaker")
            self.adjust_for_noise("Default Speaker", "Please make or play some noise from the Default Speaker...")
        finally:
            p.terminate()

    def list_all_speakers(self, p):
      print('Available speakers:')
      for i in range(p.get_device_count()):
        device_info = p.get_device_info_by_index(i)
        print(f"Speaker {i}: {device_info['name']}")
        # Speaker 0: Florians AirPods
        # Speaker 1: Florians AirPods
        # Speaker 2: Flo Microphone
        # Speaker 3: U32R59x
        # Speaker 4: MacBook Pro Microphone
        # Speaker 5: MacBook Pro Speakers
        # Speaker 6: Microsoft Teams Audio
        # Speaker 7: ZoomAudioDevice

However, I still get every audio duplicated in the UI like:

You: [so I'm ready now]
Speaker: [So, I am ready now.]

Do you have a hint how to change the device index? Is the separation between You and Speaker working fine for you? Do you use a headset?

@victoryg739
Copy link

is there any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants