Add C++ runtime for Matcha-TTS (#1627)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "sherpa-onnx/csrc/offline-tts-impl.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
#include "android/asset_manager.h"
|
||||
@@ -15,21 +16,39 @@
|
||||
#include "rawfile/raw_file_manager.h"
|
||||
#endif
|
||||
|
||||
#include "sherpa-onnx/csrc/offline-tts-matcha-impl.h"
|
||||
#include "sherpa-onnx/csrc/offline-tts-vits-impl.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
std::vector<int64_t> OfflineTtsImpl::AddBlank(const std::vector<int64_t> &x,
|
||||
int32_t blank_id /*= 0*/) const {
|
||||
// we assume the blank ID is 0
|
||||
std::vector<int64_t> buffer(x.size() * 2 + 1, blank_id);
|
||||
int32_t i = 1;
|
||||
for (auto k : x) {
|
||||
buffer[i] = k;
|
||||
i += 2;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
std::unique_ptr<OfflineTtsImpl> OfflineTtsImpl::Create(
|
||||
const OfflineTtsConfig &config) {
|
||||
// TODO(fangjun): Support other types
|
||||
return std::make_unique<OfflineTtsVitsImpl>(config);
|
||||
if (!config.model.vits.model.empty()) {
|
||||
return std::make_unique<OfflineTtsVitsImpl>(config);
|
||||
}
|
||||
return std::make_unique<OfflineTtsMatchaImpl>(config);
|
||||
}
|
||||
|
||||
template <typename Manager>
|
||||
std::unique_ptr<OfflineTtsImpl> OfflineTtsImpl::Create(
|
||||
Manager *mgr, const OfflineTtsConfig &config) {
|
||||
// TODO(fangjun): Support other types
|
||||
return std::make_unique<OfflineTtsVitsImpl>(mgr, config);
|
||||
if (!config.model.vits.model.empty()) {
|
||||
return std::make_unique<OfflineTtsVitsImpl>(mgr, config);
|
||||
}
|
||||
|
||||
return std::make_unique<OfflineTtsMatchaImpl>(mgr, config);
|
||||
}
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
|
||||
Reference in New Issue
Block a user