mirror of
https://github.com/pstrueb/piper.git
synced 2026-06-11 06:02:26 +00:00
Upgrade to onnxruntime 1.13.1
This commit is contained in:
+3
-3
@@ -36,7 +36,7 @@ COPY lib/ ./lib/
|
||||
RUN mkdir -p /usr/local/include/onnxruntime && \
|
||||
tar -C /usr/local/include/onnxruntime \
|
||||
--strip-components 1 \
|
||||
-xvf "lib/onnxruntime-${TARGETARCH}${TARGETVARIANT}.tgz"
|
||||
-xvf "lib/onnxruntime-linux-${TARGETARCH}${TARGETVARIANT}.tgz"
|
||||
|
||||
# Build larynx binary
|
||||
COPY Makefile ./
|
||||
@@ -50,10 +50,10 @@ RUN mkdir -p larynx && \
|
||||
cp -dR /usr/share/espeak-ng-data ./larynx/ && \
|
||||
cp -d /usr/local/include/onnxruntime/lib/libonnxruntime.so.* ./larynx/ && \
|
||||
cp /build/build/larynx ./larynx/ && \
|
||||
tar -czf larynx.tar.gz larynx/
|
||||
tar -czf "larynx_${TARGETARCH}${TARGETVARIANT}.tar.gz" larynx/
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=build /dist/larynx.tar.gz ./
|
||||
COPY --from=build /dist/larynx_*.tar.gz ./
|
||||
|
||||
@@ -31,7 +31,7 @@ Download a release:
|
||||
* [amd64](https://github.com/rhasspy/larynx2/releases/download/v0.0.1/larynx_amd64.tar.gz) (desktop Linux)
|
||||
* [arm64](https://github.com/rhasspy/larynx2/releases/download/v0.0.1/larynx_arm64.tar.gz) (Raspberry Pi 4)
|
||||
|
||||
If you want to build from source, see the [Makefile](Makefile) and [C++ source](src/cpp).
|
||||
If you want to build from source, see the [Makefile](Makefile) and [C++ source](src/cpp). Last tested with [onnxruntime](https://github.com/microsoft/onnxruntime) 1.13.1.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
onnxruntime-linux-x64-1.12.1.tgz
|
||||
@@ -1 +0,0 @@
|
||||
onnxruntime-linux-aarch64-1.12.1.tgz
|
||||
@@ -1 +0,0 @@
|
||||
/home/hansenm/opt/mimic3-cpp/lib/onnxruntime-linux-armhf-1.12.0.tgz
|
||||
Binary file not shown.
Binary file not shown.
Symlink
+1
@@ -0,0 +1 @@
|
||||
onnxruntime-linux-x64-1.13.1.tgz
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
onnxruntime-linux-aarch64-1.13.1.tgz
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,8 +12,6 @@ const string instanceName{"larynx"};
|
||||
|
||||
struct ModelSession {
|
||||
Ort::Session onnx;
|
||||
vector<char *> inputNames;
|
||||
vector<char *> outputNames;
|
||||
Ort::AllocatorWithDefaultOptions allocator;
|
||||
Ort::SessionOptions options;
|
||||
Ort::Env env;
|
||||
@@ -48,19 +46,6 @@ void loadModel(string modelPath, ModelSession &session) {
|
||||
session.onnx = Ort::Session(session.env, modelPath.c_str(), session.options);
|
||||
auto endTime = chrono::steady_clock::now();
|
||||
auto loadDuration = chrono::duration<double>(endTime - startTime);
|
||||
|
||||
size_t numInputNodes = session.onnx.GetInputCount();
|
||||
size_t numOutputNodes = session.onnx.GetOutputCount();
|
||||
|
||||
for (size_t i = 0; i < numInputNodes; i++) {
|
||||
session.inputNames.push_back(
|
||||
session.onnx.GetInputName(i, session.allocator));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < numOutputNodes; i++) {
|
||||
session.outputNames.push_back(
|
||||
session.onnx.GetOutputName(i, session.allocator));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace larynx
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SYNTHESIZE_H_
|
||||
#define SYNTHESIZE_H_
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
@@ -64,12 +65,16 @@ void synthesize(SynthesisConfig &synthesisConfig, ModelSession &session,
|
||||
speakerIdShape.size()));
|
||||
}
|
||||
|
||||
// From export_onnx.py
|
||||
array<const char *, 4> inputNames = {"input", "input_lengths", "scales",
|
||||
"sid"};
|
||||
array<const char *, 1> outputNames = {"output"};
|
||||
|
||||
// Infer
|
||||
auto startTime = chrono::steady_clock::now();
|
||||
auto outputTensors =
|
||||
session.onnx.Run(Ort::RunOptions{nullptr}, session.inputNames.data(),
|
||||
inputTensors.data(), inputTensors.size(),
|
||||
session.outputNames.data(), session.outputNames.size());
|
||||
auto outputTensors = session.onnx.Run(
|
||||
Ort::RunOptions{nullptr}, inputNames.data(), inputTensors.data(),
|
||||
inputTensors.size(), outputNames.data(), outputNames.size());
|
||||
auto endTime = chrono::steady_clock::now();
|
||||
|
||||
if ((outputTensors.size() != 1) || (!outputTensors.front().IsTensor())) {
|
||||
|
||||
Reference in New Issue
Block a user