Internal change
PiperOrigin-RevId: 544563029
This commit is contained in:
parent
687075e5b8
commit
6c7aa8a0d6
|
@ -282,18 +282,23 @@ 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);
|
||||||
}
|
}
|
||||||
RET_CHECK(kAudioSampleRateIn(cc).IsConnected() ^
|
if (options.has_source_sample_rate()) {
|
||||||
!kAudioIn(cc).Header().IsEmpty())
|
source_sample_rate_ = options.source_sample_rate();
|
||||||
<< "Must either specify the time series header of the \"AUDIO\" stream "
|
} else {
|
||||||
"or have the \"SAMPLE_RATE\" stream connected.";
|
RET_CHECK(kAudioSampleRateIn(cc).IsConnected() ^
|
||||||
if (!kAudioIn(cc).Header().IsEmpty()) {
|
!kAudioIn(cc).Header().IsEmpty())
|
||||||
mediapipe::TimeSeriesHeader input_header;
|
<< "Must either specify the time series header of the \"AUDIO\" stream "
|
||||||
MP_RETURN_IF_ERROR(mediapipe::time_series_util::FillTimeSeriesHeaderIfValid(
|
"or have the \"SAMPLE_RATE\" stream connected.";
|
||||||
kAudioIn(cc).Header(), &input_header));
|
if (!kAudioIn(cc).Header().IsEmpty()) {
|
||||||
if (stream_mode_) {
|
mediapipe::TimeSeriesHeader input_header;
|
||||||
MP_RETURN_IF_ERROR(SetupStreamingResampler(input_header.sample_rate()));
|
MP_RETURN_IF_ERROR(
|
||||||
} else {
|
mediapipe::time_series_util::FillTimeSeriesHeaderIfValid(
|
||||||
source_sample_rate_ = input_header.sample_rate();
|
kAudioIn(cc).Header(), &input_header));
|
||||||
|
if (stream_mode_) {
|
||||||
|
MP_RETURN_IF_ERROR(SetupStreamingResampler(input_header.sample_rate()));
|
||||||
|
} else {
|
||||||
|
source_sample_rate_ = input_header.sample_rate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppendZerosToSampleBuffer(padding_samples_before_);
|
AppendZerosToSampleBuffer(padding_samples_before_);
|
||||||
|
|
|
@ -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