AudioIO: add dnn speech recognition sample on C++#21458
Merged
alalek merged 5 commits intoopencv:4.xfrom Feb 28, 2022
Merged
Conversation
alalek
reviewed
Jan 18, 2022
Qannaf
suggested changes
Jan 24, 2022
samples/dnn/speech_recognition.cpp
Outdated
| return res; | ||
| } | ||
|
|
||
| std::vector<std::vector<double>> mel(int n_mels, double fmin, double fmax) |
There was a problem hiding this comment.
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) |
samples/dnn/speech_recognition.cpp
Outdated
| } | ||
|
|
||
| // STFT preperation | ||
| std::vector<double> pad_window_center(std::vector<double>&data, int size) |
There was a problem hiding this comment.
Suggested change
| std::vector<double> pad_window_center(std::vector<double>&data, int size) | |
| vector<double> pad_window_center(vector<double>&data, int size) |
samples/dnn/speech_recognition.cpp
Outdated
| // 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; |
There was a problem hiding this comment.
Suggested change
| std::vector<double> pad_array; | |
| vector<double> pad_array; |
samples/dnn/speech_recognition.cpp
Outdated
| return pad_array; | ||
| } | ||
|
|
||
| std::vector<std::vector<double>> frame(std::vector<double>& x) |
There was a problem hiding this comment.
Suggested change
| std::vector<std::vector<double>> frame(std::vector<double>& x) | |
| vector<vector<double>> frame(vector<double>& x) |
samples/dnn/speech_recognition.cpp
Outdated
| { | ||
| // 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)); |
There was a problem hiding this comment.
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)); |
samples/dnn/speech_recognition.cpp
Outdated
| std::vector<double> hanning() | ||
| { | ||
| // https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows | ||
| std::vector<double> window_tensor; |
There was a problem hiding this comment.
Suggested change
| std::vector<double> window_tensor; | |
| vector<double> window_tensor; |
samples/dnn/speech_recognition.cpp
Outdated
| return window_tensor; | ||
| } | ||
|
|
||
| std::vector<std::vector<double>> stft_power(std::vector<double>& y) |
There was a problem hiding this comment.
Suggested change
| std::vector<std::vector<double>> stft_power(std::vector<double>& y) | |
| vector<vector<double>> stft_power(vector<double>& y) |
samples/dnn/speech_recognition.cpp
Outdated
| // https://en.wikipedia.org/wiki/Short-time_Fourier_transform | ||
|
|
||
| // Pad the time series so that frames are centered | ||
| std::vector<double> new_y; |
There was a problem hiding this comment.
Suggested change
| std::vector<double> new_y; | |
| vector<double> new_y; |
Merged
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.