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

VoiceNext VoiceReceive #1910

Open
bourk94 opened this issue May 17, 2024 · 0 comments
Open

VoiceNext VoiceReceive #1910

bourk94 opened this issue May 17, 2024 · 0 comments

Comments

@bourk94
Copy link

bourk94 commented May 17, 2024

Summary

I want to launch commands with my voice using picovoice porcupine. On discord desktop the wakeword is not detected but on the mobile app it is. I tried recording the audio and the audio recorded from the mobile app is perfectly clear while the audio from the desktop app is distorted.

What version of the library are you using?

v4.4.6 (Stable)

What .NET version are you using? Make sure to use the latest patch release for your major version.

.NET 6.0

Operating System

No response

Reproduction Steps

    public async Task ReceiveHandler(VoiceNextConnection _, VoiceReceiveEventArgs args)
    {
        short[] frame = new short[porcupine.FrameLength];

        byte[] pcmData = args.PcmData.ToArray();

        short[] audioFrame = new short[pcmData.Length / sizeof(short)];
        Buffer.BlockCopy(pcmData, 0, audioFrame, 0, pcmData.Length);

        if (audioFrame.Length > porcupine.FrameLength)
        {
            int offset = audioFrame.Length - porcupine.FrameLength;

            for (int i = 0; i + porcupine.FrameLength <= audioFrame.Length; i += offset)
            {
                Array.Copy(audioFrame, i, frame, 0, porcupine.FrameLength);
            }
        }
        else
        {
            for (int i = 0; i < audioFrame.Length; i += porcupine.FrameLength)
            {
                int remaining = audioFrame.Length - i;
                Array.Copy(audioFrame, i, frame, 0, Math.Min(remaining, porcupine.FrameLength));

                if (remaining < porcupine.FrameLength)
                {
                    for (int j = remaining; j < porcupine.FrameLength; j++)
                    {
                        frame[j] = 0;
                    }
                }
            }
        }

        if (porcupine != null)
        {
            int keywordIndex = porcupine.Process(frame);
            if (keywordIndex >= 0)
            {
                await commandRoulette.RouletteStrat(commandContext);
            }
        }

        await Task.Yield();
    }

Trace Logs

No response

Exceptions or other error messages

No response

Anything else you'd like to share

No response

@bourk94 bourk94 added the bug label May 17, 2024
@akiraveliara akiraveliara added this to the Backlog milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants