Voice CLI

CLI commands for text-to-speech and speech-to-text

Diagram

User

Agent

Output

Voice CLI Commands

The praisonai-ts CLI provides the voice command for text-to-speech and speech-to-text operations using OpenAI.

Quick Start

  1. Simple Usage
    typescript
    import { createOpenAIVoice } from 'praisonai';
    
    const voice = createOpenAIVoice();
    
    // Text to speech
    const audio = await voice.speak("Hello world", { voice: 'nova' });
    
    // Speech to text
    const text = await voice.listen(audioBuffer);
  2. With Configuration

    See the sections below for advanced options.


Commands Overview

CommandDescription
voice speak <text>Convert text to speech
voice transcribe <file>Transcribe audio file to text
voice voicesList available voices
voice providersList voice providers
voice helpShow help

Text-to-Speech

Convert text to audio:

bash
# Basic speech generation
praisonai-ts voice speak "Hello, how are you today?"

# Specify a voice
praisonai-ts voice speak "Welcome to PraisonAI" --voice nova

# Specify output file
praisonai-ts voice speak "Hello world" --file greeting.mp3

# JSON output
praisonai-ts voice speak "Test message" --json

Example Output:

✓ Speech saved to: speech_1705123456789.mp3
  Size: 45632 bytes

JSON Output:

json
{
  "success": true,
  "data": {
    "text": "Hello world",
    "voice": "alloy",
    "file": "greeting.mp3",
    "size": 45632
  }
}

Speech-to-Text

Transcribe audio files:

bash
# Transcribe an audio file
praisonai-ts voice transcribe recording.mp3

# JSON output
praisonai-ts voice transcribe meeting.wav --json

Example Output:

Transcription

Hello, this is a test recording for the voice transcription feature.

JSON Output:

json
{
  "success": true,
  "data": {
    "file": "recording.mp3",
    "text": "Hello, this is a test recording..."
  }
}

List Voices

View available voice options:

bash
praisonai-ts voice voices
praisonai-ts voice voices --json

Available Voices:

VoiceStyleBest For
alloyNeutral, balancedGeneral purpose
echoWarm, engagingConversational
fableExpressive, dynamicStorytelling
onyxDeep, authoritativeProfessional
novaFriendly, brightCustomer service
shimmerClear, optimisticTutorials

Options

OptionDescriptionDefault
--voice <name>Voice to usealloy
--file <path>Output file pathAuto-generated
--jsonJSON outputfalse

Environment Variables

bash
# Required for voice features
export OPENAI_API_KEY=sk-...

SDK Usage

For programmatic voice usage:

typescript
import { createOpenAIVoice } from 'praisonai';

const voice = createOpenAIVoice();

// Text to speech
const audio = await voice.speak("Hello world", { voice: 'nova' });

// Speech to text
const text = await voice.listen(audioBuffer);

For more details, see the Voice SDK documentation.

Related