Skip to content

πŸ‘οΈ Arietta Recognition is a collection of AI systems that can be used to recognize and understand the world around us.

License

Notifications You must be signed in to change notification settings

Arietta-Studio/arietta-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Arietta Recognition

A high-quality & reliable recognition toolkit for various data types, including Text-to-Speech (TTS) and Speech-to-Text (STT).



Changelog Β· Report Bug Β· Request Feature

Table of contents

TOC

πŸ“– Introduction

πŸ€– Arietta Recognition is a high-quality and reliable recognition toolkit for various data types, including Text-to-Speech (TTS) and Speech-to-Text (STT). It is developed by [Arietta Studio]

Note

Therefore, we decided to refine our implementation and make it open source, hoping to assist developers who wish to implement TTS. @arietta-studio/recognition is a high-quality TTS toolkit developed in TypeScript, which supports usage both on the server-side and in the browser.

  • Server-side: With just 15 lines of code, you can achieve high-quality voice generation capabilities comparable to OpenAI's TTS service. It currently supports EdgeSpeechTTS, MicrosoftTTS, OpenAITTS, and OpenAISTT.
  • Browser-side: It provides high-quality React Hooks and visual audio components, supporting common functions such as loading, playing, pausing, and dragging the timeline. Additionally, it offers a very rich set of capabilities for adjusting the audio track styles.

πŸ“¦ Usage

Generate Speech on server

run the script below use Bun: bun index.js

// index.js
import { EdgeSpeechTTS } from '@arietta-studio/recognition';
import { Buffer } from 'buffer';
import fs from 'fs';
import path from 'path';

// Instantiate EdgeSpeechTTS
const tts = new EdgeSpeechTTS({ locale: 'en-US' });

// Create speech synthesis request payload
const payload = {
  input: 'This is a speech demonstration',
  options: {
    voice: 'en-US-GuyNeural',
  },
};

// Call create method to synthesize speech
const response = await tts.create(payload);

// generate speech file
const mp3Buffer = Buffer.from(await response.arrayBuffer());
const speechFile = path.resolve('./speech.mp3');

fs.writeFileSync(speechFile, mp3Buffer);

Important

Run on Node.js

As the Node.js environment lacks the WebSocket instance, we need to polyfill WebSocket. This can be done by importing the ws package.

// import at the top of the file
import WebSocket from 'ws';

global.WebSocket = WebSocket;

Use the React Component

import { AudioPlayer, AudioVisualizer, useAudioPlayer } from '@arietta-studio/recognition/react';

export default () => {
  const { ref, isLoading, ...audio } = useAudioPlayer(url);

  return (
    <Flexbox align={'center'} gap={8}>
      <AudioPlayer audio={audio} isLoading={isLoading} style={{ width: '100%' }} />
      <AudioVisualizer audioRef={ref} isLoading={isLoading} />
    </Flexbox>
  );
};

πŸ“¦ Installation

Important

This package is ESM only.

To install @arietta-studio/recognition, run the following command:

$ pnpm i @arietta-studio/recognition

$ bun add @arietta-studio/recognition

Compile with Next.js

Note

By work correct with Next.js SSR, add transpilePackages: ['@arietta-studio/recognition'] to next.config.js. For example:

const nextConfig = {
  transpilePackages: ['@arietta-studio/recognition'],
};

⌨️ Local Development

You can use Github Codespaces for online development:

Or clone it for local development:

$ git clone https://github.com/arietta-studio/arietta-recognition.git
$ cd arietta-recognition
$ bun install
$ bun dev

🀝 Contributing

Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub Issues to get stuck in to show us what you’re made of.

🩷 Sponsor

Every bit counts and your one-time donation sparkles in our galaxy of support! You're a shooting star, making a swift and bright impact on our journey. Thank you for believing in us – your generosity guides us toward our mission, one brilliant flash at a time.


πŸ“ License

Copyright Β© 2024 Arietta Studio.
This project is MIT licensed.

About

πŸ‘οΈ Arietta Recognition is a collection of AI systems that can be used to recognize and understand the world around us.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages