Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

vits-piper-en_GB-vctk-medium

Info about this model

This model is converted from https://huggingface.co/rhasspy/piper-voices/tree/main/en/en_GB/vctk/medium

Number of speakersSample rate
10922050

Model download address

https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_GB-vctk-medium.tar.bz2

Android APK

The following table shows the Android TTS Engine APK with this model for sherpa-onnx v1.12.1

ABIURL中国镜像
arm64-v8aDownload下载
armeabi-v7aDownload下载
x86_64Download下载
x86Download下载

If you don't know what ABI is, you probably need to select arm64-v8a.

The source code for the APK can be found at

https://github.com/k2-fsa/sherpa-onnx/tree/master/android/SherpaOnnxTtsEngine

Please refer to the documentation for how to build the APK from source code.

More Android APKs can be found at

https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html

C API

You can use the following code to play with vits-piper-en_GB-vctk-medium with C API.

#include <stdio.h>
#include <string.h>

#include "sherpa-onnx/c-api/c-api.h"

int main() {
  SherpaOnnxOfflineTtsConfig config;
  memset(&config, 0, sizeof(config));

  config.model.vits.model = "vits-piper-en_GB-vctk-medium/en_GB-vctk-medium.onnx";
  config.model.vits.tokens = "vits-piper-en_GB-vctk-medium/tokens.txt";
  config.model.vits.data_dir = "vits-piper-en_GB-vctk-medium/espeak-ng-data";
  config.model.num_threads = 1;
  const SherpaOnnxOfflineTts *tts = SherpaOnnxCreateOfflineTts(&config);

  int sid = 0; // speaker id
  const char *text = "Friends fell out often because life was changing so fast. The easiest thing in the world was to lose touch with someone.";

  const SherpaOnnxGeneratedAudio *audio =
      SherpaOnnxOfflineTtsGenerate(tts, text, sid, 1.0);

  SherpaOnnxWriteWave(audio->samples, audio->n, audio->sample_rate,
                      "./test.wav");

  // You need to free the pointers to avoid memory leak in your app
  SherpaOnnxDestroyOfflineTtsGeneratedAudio(audio);
  SherpaOnnxDestroyOfflineTts(tts);

  printf("Saved to ./test.wav\n");

  return 0;
}

In the following, we describe how to compile and run the above C example.

cd /tmp
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
mkdir build-shared
cd build-shared

cmake  -DSHERPA_ONNX_ENABLE_C_API=ON  -DCMAKE_BUILD_TYPE=Release  -DBUILD_SHARED_LIBS=ON  -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared  ..

make
make install

You can find required header file and library files inside /tmp/sherpa-onnx/shared.

Assume you have saved the above example file as /tmp/test-piper.c. Then you can compile it with the following command:

gcc   -I /tmp/sherpa-onnx/shared/include   -L /tmp/sherpa-onnx/shared/lib   -lsherpa-onnx-c-api   -lonnxruntime   -o /tmp/test-piper   /tmp/test-piper.c

Now you can run

cd /tmp

# Assume you have downloaded the model and extracted it to /tmp
./test-piper

You probably need to run

# For Linux
export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH

# For macOS
export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATH

before you run /tmp/test-piper.

Please see the documentation at

https://k2-fsa.github.io/sherpa/onnx/c-api/index.html

Python API

Assume you have installed sherpa-onnx via

pip install sherpa-onnx

and you have downloaded the model from

https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_GB-vctk-medium.tar.bz2

You can use the following code to play with vits-piper-en_GB-vctk-medium

import sherpa_onnx
import soundfile as sf

config = sherpa_onnx.OfflineTtsConfig(
    model=sherpa_onnx.OfflineTtsModelConfig(
        vits=sherpa_onnx.OfflineTtsVitsModelConfig(
            model="vits-piper-en_GB-vctk-medium/en_GB-vctk-medium.onnx",
            lexicon="",
            data_dir="vits-piper-en_GB-vctk-medium/espeak-ng-data",
            tokens="vits-piper-en_GB-vctk-medium/tokens.txt",
        ),
        num_threads=1,
    ),
)

if not config.validate():
    raise ValueError("Please check your config")

tts = sherpa_onnx.OfflineTts(config)
audio = tts.generate(text="Friends fell out often because life was changing so fast. The easiest thing in the world was to lose touch with someone.",
                     sid=0,
                     speed=1.0)

sf.write("test.mp3", audio.samples, samplerate=audio.sample_rate)

Samples

For the following text:

Friends fell out often because life was changing so fast.
The easiest thing in the world was to lose touch with someone.

sample audios for different speakers are listed below:

Speaker 0

Speaker 1

Speaker 2

Speaker 3

Speaker 4

Speaker 5

Speaker 6

Speaker 7

Speaker 8

Speaker 9

Speaker 10

Speaker 11

Speaker 12

Speaker 13

Speaker 14

Speaker 15

Speaker 16

Speaker 17

Speaker 18

Speaker 19

Speaker 20

Speaker 21

Speaker 22

Speaker 23

Speaker 24

Speaker 25

Speaker 26

Speaker 27

Speaker 28

Speaker 29

Speaker 30

Speaker 31

Speaker 32

Speaker 33

Speaker 34

Speaker 35

Speaker 36

Speaker 37

Speaker 38

Speaker 39

Speaker 40

Speaker 41

Speaker 42

Speaker 43

Speaker 44

Speaker 45

Speaker 46

Speaker 47

Speaker 48

Speaker 49

Speaker 50

Speaker 51

Speaker 52

Speaker 53

Speaker 54

Speaker 55

Speaker 56

Speaker 57

Speaker 58

Speaker 59

Speaker 60

Speaker 61

Speaker 62

Speaker 63

Speaker 64

Speaker 65

Speaker 66

Speaker 67

Speaker 68

Speaker 69

Speaker 70

Speaker 71

Speaker 72

Speaker 73

Speaker 74

Speaker 75

Speaker 76

Speaker 77

Speaker 78

Speaker 79

Speaker 80

Speaker 81

Speaker 82

Speaker 83

Speaker 84

Speaker 85

Speaker 86

Speaker 87

Speaker 88

Speaker 89

Speaker 90

Speaker 91

Speaker 92

Speaker 93

Speaker 94

Speaker 95

Speaker 96

Speaker 97

Speaker 98

Speaker 99

Speaker 100

Speaker 101

Speaker 102

Speaker 103

Speaker 104

Speaker 105

Speaker 106

Speaker 107

Speaker 108