kaldi-native-fbank C++ API
Kaldi-compatible feature extraction C++ API
Loading...
Searching...
No Matches
whisper-feature.h File Reference

Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang). More...

#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include "kaldi-native-fbank/csrc/feature-window.h"
#include "kaldi-native-fbank/csrc/mel-computations.h"
Include dependency graph for whisper-feature.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  knf::WhisperFeatureOptions
 Options for computing Whisper mel features. More...
class  knf::WhisperFeatureComputer
 Class for computing Whisper mel features. More...

Namespaces

namespace  knf
 This file is part of kaldi-native-fbank.

Detailed Description

Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang).

See LICENSE for clarification regarding multiple authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Mel features for OpenAI Whisper models.

This is not from kaldi. It computes the mel power spectrum used by Whisper models. Note it does not apply the final log compression; the caller is expected to do that. For a mel power spectrum \( x \):

\[ x \leftarrow \max(x, 10^{-10}) \]

\[ y = \log_{10} x \]

\[ y \leftarrow \max(y,\, \max(y) - 8) \]

\[ \mathrm{mel} = (y + 4) / 4 \]

Input samples should be normalized into the range [-1, 1].