Skip to content

AudioIO: add dnn speech recognition sample on C++#21458

Merged
alalek merged 5 commits intoopencv:4.xfrom
SinM9:speech_recognition_cpp
Feb 28, 2022
Merged

AudioIO: add dnn speech recognition sample on C++#21458
alalek merged 5 commits intoopencv:4.xfrom
SinM9:speech_recognition_cpp

Conversation

@SinM9
Copy link
Copy Markdown
Contributor

@SinM9 SinM9 commented Jan 16, 2022

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

return res;
}

std::vector<std::vector<double>> mel(int n_mels, double fmin, double fmax)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<std::vector<double>> mel(int n_mels, double fmin, double fmax)
vector<vector<double>> mel(int n_mels, double fmin, double fmax)

}

// STFT preperation
std::vector<double> pad_window_center(std::vector<double>&data, int size)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<double> pad_window_center(std::vector<double>&data, int size)
vector<double> pad_window_center(vector<double>&data, int size)

// Pad the window out to n_fft size
int n = static_cast<int>(data.size());
int lpad = static_cast<int>((size - n) / 2);
std::vector<double> pad_array;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<double> pad_array;
vector<double> pad_array;

return pad_array;
}

std::vector<std::vector<double>> frame(std::vector<double>& x)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<std::vector<double>> frame(std::vector<double>& x)
vector<vector<double>> frame(vector<double>& x)

{
// Slices a data array into overlapping frames.
int n_frames = static_cast<int>(1 + (x.size() - n_fft) / hop_length);
std::vector<std::vector<double>> new_x(n_fft, std::vector<double>(n_frames));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<std::vector<double>> new_x(n_fft, std::vector<double>(n_frames));
vector<vector<double>> new_x(n_fft, vector<double>(n_frames));

std::vector<double> hanning()
{
// https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows
std::vector<double> window_tensor;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<double> window_tensor;
vector<double> window_tensor;

return window_tensor;
}

std::vector<std::vector<double>> stft_power(std::vector<double>& y)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<std::vector<double>> stft_power(std::vector<double>& y)
vector<vector<double>> stft_power(vector<double>& y)

// https://en.wikipedia.org/wiki/Short-time_Fourier_transform

// Pad the time series so that frames are centered
std::vector<double> new_y;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<double> new_y;
vector<double> new_y;

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for update!

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 👍

@alalek alalek merged commit a332509 into opencv:4.x Feb 28, 2022
@opencv-pushbot opencv-pushbot mentioned this pull request Apr 23, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
AudioIO: add dnn speech recognition sample on C++

* add speech recognition cpp

* fix warnings

* fixes

* fix warning

* microphone fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants