diff --git a/speechx/speechx/frontend/feature_cache.h b/speechx/speechx/frontend/feature_cache.h index c7d66251..5849cc5c 100644 --- a/speechx/speechx/frontend/feature_cache.h +++ b/speechx/speechx/frontend/feature_cache.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once + #include "base/common.h" #include "frontend/feature_extractor_interface.h" @@ -45,4 +47,4 @@ class FeatureCache : public FeatureExtractorInterface { // DISALLOW_COPY_AND_ASSGIN(FeatureCache); }; -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech diff --git a/speechx/speechx/frontend/raw_audio.cc b/speechx/speechx/frontend/raw_audio.cc index 0c7f4d21..1e265a57 100644 --- a/speechx/speechx/frontend/raw_audio.cc +++ b/speechx/speechx/frontend/raw_audio.cc @@ -35,7 +35,6 @@ void RawAudioSource::AcceptWaveform(const VectorBase& data) { ring_buffer_[idx % ring_buffer_.size()] = data(idx); } data_length_ += data.Dim(); - ready_read_condition_.notify_one(); } // bool RawAudioSource::AcceptWaveform(BaseFloat* data, int length) { @@ -53,7 +52,7 @@ bool RawAudioSource::Read(Vector* feat) { std::unique_lock lock(mutex_); while (chunk_size > data_length_) { // when audio is empty and no more data feed - // ready_read_condition will block in dead lock. + // ready_read_condition will block in dead lock. so replace with timeout_ // ready_read_condition_.wait(lock); int32 elapsed = static_cast(timer.Elapsed() * 1000); if (elapsed > timeout_) { @@ -82,4 +81,4 @@ bool RawAudioSource::Read(Vector* feat) { return true; } -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech diff --git a/speechx/speechx/frontend/raw_audio.h b/speechx/speechx/frontend/raw_audio.h index 1893da25..c3ebe559 100644 --- a/speechx/speechx/frontend/raw_audio.h +++ b/speechx/speechx/frontend/raw_audio.h @@ -18,8 +18,6 @@ #include "base/common.h" #include "frontend/feature_extractor_interface.h" -#pragma once - namespace ppspeech { class RawAudioSource : public FeatureExtractorInterface { @@ -40,7 +38,6 @@ class RawAudioSource : public FeatureExtractorInterface { size_t data_length_; bool finished_; mutable std::mutex mutex_; - std::condition_variable ready_read_condition_; std::condition_variable ready_feed_condition_; kaldi::int32 timeout_; @@ -74,4 +71,4 @@ class RawDataSource : public FeatureExtractorInterface { DISALLOW_COPY_AND_ASSIGN(RawDataSource); }; -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech