Code Monkey home page Code Monkey logo

ntts_flutter's Introduction

Neural Text To Speech

Neural Text To Speech Library untuk menghasilkan suara realistis seperti natural di bahasa dart, neural text to speech ini berjalan tanpa perlu koneksi internet dan hanya membutuhkan cpu saja

Demo

ewfile.mp4

More Update And More Features?

Indonesia: jika anda ingin saya maintance terus project ini silahkan donate ke saya
English: if you want me to continue to maintain this project please donate to me

TESTED ON

NO OS CPU RAM
1 Ubuntu 22.04 AMD RYZEN 5500U 8GB
2 Ubuntu Server 22.04 Intel Celeron n2940 4GB

Resources

No Name
1 MODEL TTS ENGLISH

Dependencies

sudo apt-get install espeak-ng mpv
sudo apt-get install gawk bison gcc make -y
wget -c https://ftp.gnu.org/gnu/glibc/glibc-2.33.tar.gz
tar -zxvf glibc-2.33.tar.gz && cd glibc-2.33
mkdir glibc-build && cd glibc-build
../configure --prefix=/opt/glibc
make
sudo make install

Installation

# download model
wget https://huggingface.co/rhasspy/piper-voices/blob/v1.0.0/en/en_US/libritts/high/en_US-libritts-high.onnx
wget https://huggingface.co/rhasspy/piper-voices/blob/v1.0.0/en/en_US/libritts/high/en_US-libritts-high.onnx.json

# download ntts
wget https://github.com/azkadev/ntts/releases/download/latest/ntts_dart.deb

# install ntts
sudo dpkg --force-all -i ./ntts_dart.deb

# try ntts
ntts_dart -m "en_US-libritts-high.onnx" -t "Hello World"

Development

git clone https://github.com/azkadev/ntts_dart.git
cd ntts_dart

Compile Library

cd native_lib
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .

Install

dart pub add ntts_dart

Import Library

import 'package:ntts_dart/ntts_dart.dart';

Quickstart

Sebelum di run pastikan kamu sudah mengcompile library dan menyiapkan model dahulu

import 'dart:io';
import 'package:galaxeus_lib/galaxeus_lib.dart';
import 'package:ntts_dart/api/create_voice.dart';
import 'package:ntts_dart/ntts_dart.dart';
import 'package:ntts_dart/scheme/scheme.dart';
import 'package:play/play_dart.dart';
import "package:path/path.dart" as path;

void main(List<String> arguments) async {
  Args args = Args(arguments);
  Ntts ntts = Ntts(
    pathLib: "libntts.so",
  );
  File file = File(path.join(Directory.current.path, "en_US-libritts-high.onnx"));
  if (!file.existsSync()) {
    print("Please add model");
    exit(0);
  }

  File file_ouput = File(path.join(Directory.current.path, "data.wav"));
  if (file_ouput.existsSync()) {
    await file_ouput.delete();
  }
  var res = ntts.invokeRaw(
    data: CreateVoice.create(
      text: """
This sound is created using dart language by azkadev without using any internet

Human: Good afternoon, robot. How are you today?

Robot: I am functioning optimally, thank you. How may I assist you?

Human: I need help with my work. Can you help me sort out my emails?

Robot: Of course, I can help you with that. May I have access to your email account?

Human: Sure, let me give you access.

(After a few seconds)

Robot: I have access to your email account now. What do you want me to do?

Human: Can you sort out my emails by date?

Robot: Certainly. Sorting your emails by date. Please wait a moment.

(After a few seconds)

Robot: Your emails have been sorted by date. Is there anything else I can assist you with?

Human: Yes, can you also search for any important emails that contain the word "urgent"?

Robot: Understood. Searching for any emails containing the word "urgent".

(After a few seconds)

Robot: I have found several emails containing the word "urgent". Would you like me to prioritize them for you?

Human: Yes, please do.

Robot: Prioritizing urgent emails. Is there anything else I can assist you with?

Human: No, that's all for now. Thank you, robot.

Robot: You're welcome. Don't hesitate to contact me if you need further assistance.

"""
          .trim(),
      model_path: file.path,
      output_file: file_ouput.path,
      speaker_id: int.tryParse(args.after("-s") ?? "0") ?? 10,
    ).toJson(),
  );

  Voice voice = Voice(res);

  Play play = Play();
  await play.open(medias: [
    voice.output_file ?? "",
  ]);
  play.player.stream.error.listen((event) {
    print(event);
  });
  // play.player.stream;
  play.player.stream.completed.listen(
    (event) {
      if (event) {
        exit(0);
      }
    },
    onDone: () {
      exit(0);
    },
  );
}

Refferensi

  1. Piper
  2. Mimic Recording Studio
  3. Espeak
  4. onnxruntime

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.