awslabs / amazon-transcribe-streaming-sdk

The Amazon Transcribe Streaming SDK is an async Python SDK for converting audio into text via Amazon Transcribe.
Apache License 2.0
142 stars 37 forks source link

record from input and output devices simultaneously #52

Open marinos123 opened 3 years ago

marinos123 commented 3 years ago

Hello, Is it possible to use input and output device simultaneously? I try the following but no luck:

    def callback(indata, outdata, frame_count, time_info, status):
        indata[:] = outdata
        loop.call_soon_threadsafe(input_queue.put_nowait, (bytes(indata), status))

    stream = sounddevice.RawStream(
        #device=3,
        channels=1,
        samplerate=16000,
        callback=callback,
        blocksize=1024 * 2,
        dtype="int16",
    )

i also try:

marinos123 commented 2 years ago

hello guys

We have tested the script with varius devices. With Corsair HS45 Surround USB Sound Adapter i was able to capture sound from both microphone and speakers, but with HP X1000 Wireless Gaming Headsetwe are unable to get any data from speakers. Here is the script:

async def mic_stream():
    # This function wraps the raw input stream from the microphone forwarding
    # the blocks to an asyncio.Queue.
    loop = asyncio.get_event_loop()
    input_queue = asyncio.Queue()

    def callback(indata, frame_count, time_info, status):
        loop.call_soon_threadsafe(input_queue.put_nowait, (bytes(indata), status))

    stream = sounddevice.RawInputStream(
        #device=[1,25],
        channels=1,
        samplerate=16000,
        callback=callback,
        blocksize=1024 * 2,
        dtype="int16",
    )
    # Initiate the audio stream and asynchronously yield the audio chunks
    # as they become available.
    with stream:
        while True:
            indata, status = await input_queue.get()
            yield indata, status

and here are the settings from the devices: Corsair HS45 Surround USB Sound Adapter

   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Headset Microphone (Corsair HS4, MME (2 in, 0 out)
   2 FrontMic (Realtek High Definiti, MME (2 in, 0 out)
   3 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
<  4 Headset Earphone (Corsair HS45 , MME (0 in, 2 out)
   5 Realtek Digital Output (Realtek, MME (0 in, 2 out)
   6 Speakers (Realtek High Definiti, MME (0 in, 2 out)

2- HP X1000 Wireless Gaming Headset (Sound Research)

   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Headset Microphone (2- HP X1000, MME (2 in, 0 out)
   2 FrontMic (Realtek High Definiti, MME (2 in, 0 out)
   3 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
<  4 Headset Earphone (2- HP X1000 W, MME (0 in, 2 out)
   5 Realtek Digital Output (Realtek, MME (0 in, 2 out)
   6 Speakers (Realtek High Definiti, MME (0 in, 2 out)   

Can anyone help?