question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hey, I wanted to use this in a c++ program, I can include the headers but have no idea how to link the dll. I’ve tried to look how to link it using CMake for a couple of days now with no success. I get C:/Users/tatan/CLionProjects/TreeVoiceAssistant/HotwordDetection.cpp:27: undefined reference to pv_porcupine_process(pv_porcupine_object*, short const*, bool*)'` every single time. I’m using CLion as you can probably see, with MINGW and I can sucessfuly include the headers, but dlls just won’t.

Please help

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
veeablefulcommented, Jun 18, 2018

Hi @dimeldo, sorry I didn’t see this sooner! I’ve created a simple example that demonstrate the usage of microphone and Porcupine in Qt. You can see it here.

1reaction
veeablefulcommented, Jun 8, 2018

@tatanpoker09 The way I do it is I buffer the audio data from microphone and process them with Porcupine once they are at least the size of Porcupine’s frame length. The result should be continuous.

In my case, I use Qt so mAudioDataBuffer is a QByteArray.

Snippet:

// Check if we have enough bytes of audio data for Porcupine to work with
bool PorcupineWaker::hasEnoughSamples(int porcupineFrameLength) const
{
    // We use porcupineFrameLength * 2 because frame length type is int16_t while mAudioDataBuffer's type is byte
    return mAudioDataBuffer.size() >= porcupineFrameLength * 2;
}

// Go through the audio data and detect the wake word if there's any
void PorcupineWaker::processSamples(int porcupineFrameLength)
{
    while (hasEnoughSamples(porcupineFrameLength)) {
        const int16_t *audioData = reinterpret_cast<int16_t*>(mAudioDataBuffer.data());
        bool detected = false;

        pv_porcupine_process(mPorcupineObject, &audioData[0], &detected);
        if (detected) {
            // Detected keyword. Do something!
            emit awake();
        }

        // Remove the audio data that we have processed
        mAudioDataBuffer.remove(0, porcupineFrameLength * 2);
    }
}

// Listen to the microphone's audio data and look for the keyword
void PorcupineWaker::listen(const QByteArray &input)
{
    const int porcupineFrameLength = pv_porcupine_frame_length();

    mAudioDataBuffer.append(input);
    processSamples(porcupineFrameLength);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Constant of integration
In calculus, the constant of integration, often denoted by C {\displaystyle C} C (or c {\displaystyle c} c ), is a constant term...
Read more >
What is this constant 'C' in integration? Why is it different ...
Integration is just opposite of differentiation so whenever we integrate without limits we add a constant C which woud vanish on ...
Read more >
Why do we add +c in integration?
The c is a constant of integration. A constant differentiated is 0, so we don't know the constant when we integrate or reverse...
Read more >
Integral Calculator • With Steps!
Solve definite and indefinite integrals (antiderivatives) using this free online calculator. Step-by-step solution and graphs included!
Read more >
C library for Numerical Integration
C library for Numerical Integration. 1 Introduction. In this project we will write multiple C-functions to calculate numerical integrals of one-dimensional.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found