forked from xiaozhi/xiaozhi-esp32
fix ReadAudioData frame duration (#1051)
This commit is contained in:
@@ -158,7 +158,7 @@ bool AudioService::ReadAudioData(std::vector<int16_t>& data, int sample_rate, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (codec_->input_sample_rate() != sample_rate) {
|
if (codec_->input_sample_rate() != sample_rate) {
|
||||||
data.resize(samples * codec_->input_sample_rate() / sample_rate);
|
data.resize(samples * codec_->input_sample_rate() / sample_rate * codec_->input_channels());
|
||||||
if (!codec_->InputData(data)) {
|
if (!codec_->InputData(data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ bool AudioService::ReadAudioData(std::vector<int16_t>& data, int sample_rate, in
|
|||||||
data = std::move(resampled);
|
data = std::move(resampled);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.resize(samples);
|
data.resize(samples * codec_->input_channels());
|
||||||
if (!codec_->InputData(data)) {
|
if (!codec_->InputData(data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ size_t AfeAudioProcessor::GetFeedSize() {
|
|||||||
if (afe_data_ == nullptr) {
|
if (afe_data_ == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return afe_iface_->get_feed_chunksize(afe_data_) * codec_->input_channels();
|
return afe_iface_->get_feed_chunksize(afe_data_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AfeAudioProcessor::Feed(std::vector<int16_t>&& data) {
|
void AfeAudioProcessor::Feed(std::vector<int16_t>&& data) {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ size_t AfeWakeWord::GetFeedSize() {
|
|||||||
if (afe_data_ == nullptr) {
|
if (afe_data_ == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return afe_iface_->get_feed_chunksize(afe_data_) * codec_->input_channels();
|
return afe_iface_->get_feed_chunksize(afe_data_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AfeWakeWord::AudioDetectionTask() {
|
void AfeWakeWord::AudioDetectionTask() {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ size_t CustomWakeWord::GetFeedSize() {
|
|||||||
if (multinet_model_data_ == nullptr) {
|
if (multinet_model_data_ == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return multinet_->get_samp_chunksize(multinet_model_data_) * codec_->input_channels();
|
return multinet_->get_samp_chunksize(multinet_model_data_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomWakeWord::StoreWakeWordData(const std::vector<int16_t>& data) {
|
void CustomWakeWord::StoreWakeWordData(const std::vector<int16_t>& data) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ size_t EspWakeWord::GetFeedSize() {
|
|||||||
if (wakenet_data_ == nullptr) {
|
if (wakenet_data_ == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return wakenet_iface_->get_samp_chunksize(wakenet_data_) * codec_->input_channels();
|
return wakenet_iface_->get_samp_chunksize(wakenet_data_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EspWakeWord::EncodeWakeWordData() {
|
void EspWakeWord::EncodeWakeWordData() {
|
||||||
|
|||||||
Reference in New Issue
Block a user