Replace Android system TTS engine (#508)

This commit is contained in:
Fangjun Kuang
2023-12-31 23:02:35 +08:00
committed by GitHub
parent e475e750ac
commit d7e10bb3f8
57 changed files with 1488 additions and 0 deletions

View File

@@ -34,6 +34,10 @@ class OfflineTtsImpl {
// Return the sample rate of the generated audio
virtual int32_t SampleRate() const = 0;
// Number of supported speakers.
// If it supports only a single speaker, then it return 0 or 1.
virtual int32_t NumSpeakers() const = 0;
};
} // namespace sherpa_onnx

View File

@@ -74,6 +74,10 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl {
return model_->GetMetaData().sample_rate;
}
int32_t NumSpeakers() const override {
return model_->GetMetaData().num_speakers;
}
GeneratedAudio Generate(
const std::string &_text, int64_t sid = 0, float speed = 1.0,
GeneratedAudioCallback callback = nullptr) const override {

View File

@@ -73,4 +73,6 @@ GeneratedAudio OfflineTts::Generate(
int32_t OfflineTts::SampleRate() const { return impl_->SampleRate(); }
int32_t OfflineTts::NumSpeakers() const { return impl_->NumSpeakers(); }
} // namespace sherpa_onnx

View File

@@ -86,6 +86,10 @@ class OfflineTts {
// Return the sample rate of the generated audio
int32_t SampleRate() const;
// Number of supported speakers.
// If it supports only a single speaker, then it return 0 or 1.
int32_t NumSpeakers() const;
private:
std::unique_ptr<OfflineTtsImpl> impl_;
};