Internal change
PiperOrigin-RevId: 544563029
This commit is contained in:
parent
687075e5b8
commit
6c7aa8a0d6
|
@ -282,13 +282,17 @@ absl::Status AudioToTensorCalculator::Open(CalculatorContext* cc) {
|
||||||
if (options.has_volume_gain_db()) {
|
if (options.has_volume_gain_db()) {
|
||||||
gain_ = pow(10, options.volume_gain_db() / 20.0);
|
gain_ = pow(10, options.volume_gain_db() / 20.0);
|
||||||
}
|
}
|
||||||
|
if (options.has_source_sample_rate()) {
|
||||||
|
source_sample_rate_ = options.source_sample_rate();
|
||||||
|
} else {
|
||||||
RET_CHECK(kAudioSampleRateIn(cc).IsConnected() ^
|
RET_CHECK(kAudioSampleRateIn(cc).IsConnected() ^
|
||||||
!kAudioIn(cc).Header().IsEmpty())
|
!kAudioIn(cc).Header().IsEmpty())
|
||||||
<< "Must either specify the time series header of the \"AUDIO\" stream "
|
<< "Must either specify the time series header of the \"AUDIO\" stream "
|
||||||
"or have the \"SAMPLE_RATE\" stream connected.";
|
"or have the \"SAMPLE_RATE\" stream connected.";
|
||||||
if (!kAudioIn(cc).Header().IsEmpty()) {
|
if (!kAudioIn(cc).Header().IsEmpty()) {
|
||||||
mediapipe::TimeSeriesHeader input_header;
|
mediapipe::TimeSeriesHeader input_header;
|
||||||
MP_RETURN_IF_ERROR(mediapipe::time_series_util::FillTimeSeriesHeaderIfValid(
|
MP_RETURN_IF_ERROR(
|
||||||
|
mediapipe::time_series_util::FillTimeSeriesHeaderIfValid(
|
||||||
kAudioIn(cc).Header(), &input_header));
|
kAudioIn(cc).Header(), &input_header));
|
||||||
if (stream_mode_) {
|
if (stream_mode_) {
|
||||||
MP_RETURN_IF_ERROR(SetupStreamingResampler(input_header.sample_rate()));
|
MP_RETURN_IF_ERROR(SetupStreamingResampler(input_header.sample_rate()));
|
||||||
|
@ -296,6 +300,7 @@ absl::Status AudioToTensorCalculator::Open(CalculatorContext* cc) {
|
||||||
source_sample_rate_ = input_header.sample_rate();
|
source_sample_rate_ = input_header.sample_rate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
AppendZerosToSampleBuffer(padding_samples_before_);
|
AppendZerosToSampleBuffer(padding_samples_before_);
|
||||||
if (options.has_fft_size()) {
|
if (options.has_fft_size()) {
|
||||||
RET_CHECK(IsValidFftSize(options.fft_size()))
|
RET_CHECK(IsValidFftSize(options.fft_size()))
|
||||||
|
|
|
@ -85,4 +85,7 @@ message AudioToTensorCalculatorOptions {
|
||||||
// The volume gain, measured in dB.
|
// The volume gain, measured in dB.
|
||||||
// Scale the input audio amplitude by 10^(volume_gain_db/20).
|
// Scale the input audio amplitude by 10^(volume_gain_db/20).
|
||||||
optional double volume_gain_db = 12;
|
optional double volume_gain_db = 12;
|
||||||
|
|
||||||
|
// The source number of samples per second (hertz) of the input audio buffers.
|
||||||
|
optional double source_sample_rate = 13;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user