Download the PHP package afaya/edge-tts without Composer

On this page you can find all versions of the php package afaya/edge-tts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package edge-tts

Edge TTS for PHP

Edge TTS turns text into natural-sounding speech with the online text-to-speech service of Microsoft Edge, without Edge, Windows or an API key.

Available in three languages

The same library for the Edge text-to-speech service, in Node.js, PHP and Go:

Language Install Repository
Node.js and browsers npm install @andresaya/edge-tts andresayac/edge-tts
PHP (this one) composer require afaya/edge-tts andresayac/edge-tts-php
Go go get github.com/andresayac/edge-tts-go andresayac/edge-tts-go

Features

Requirements

Installation

Quick start

Command-line interface

Option Description Default
-t, --text Text to convert to audio
-f, --file Input file (text); --file=- reads from stdin
--voice Voice to use en-US-AriaNeural
-r, --rate Rate of speech 0%
-l, --volume Volume of speech 0%
-p, --pitch Pitch of speech 0Hz
-o, --output Output file name; the extension is added when missing output_<timestamp>
--format Output format audio-24khz-48kbitrate-mono-mp3
--subtitles Write subtitles: .srt, or .vtt for WebVTT

edge-tts:synthesize and edge-tts:voice-list still work as names of the commands.

API

Configuration

Every option is optional. The defaults come from Constants, so when Microsoft changes the service you can set the new values yourself instead of waiting for a release.

A misspelled option throws InvalidArgumentException.

Voices

Each voice has Name, OriginalName, ShortName, DisplayName, LocalName, Gender, Locale, LocaleName, SecondaryLocaleList, VoiceType, VoiceTag and FriendlyName.

Synthesis

Every option is optional, and numbers work too: 'rate' => 50 is +50% and 'pitch' => -5 is -5Hz.

Output formats

Constants::OUTPUT_FORMAT key Format Extension
AUDIO_24KHZ_48KBITRATE_MONO_MP3 (default) audio-24khz-48kbitrate-mono-mp3 .mp3
AUDIO_24KHZ_96KBITRATE_MONO_MP3 audio-24khz-96kbitrate-mono-mp3 .mp3
WEBM_24KHZ_16BIT_MONO_OPUS webm-24khz-16bit-mono-opus .webm

These are the only formats the service accepts. It refuses the other Azure formats (WAV, PCM, OGG, 48 kHz MP3...) with "Unsupported Edge output format".

Matching the voice to the text

Voices are locale specific. A voice can only read text written in the script of its own language, so passing Chinese, Cyrillic, Arabic or Devanagari text to an English voice returns no audio. synthesize() then throws EmptyAudioException:

Streaming

stream() yields the audio as it arrives, so you can start playing or sending it before the synthesis ends:

Leaving the loop early closes the connection. If you prefer a callback:

Everything in one result

generate() returns the audio, the boundaries and the duration in a SynthesisResult, and leaves the instance as it was:

Getting the audio

After synthesize(), stream() or synthesizeStream():

Word and sentence boundaries

The service leaves the opening punctuation out of its sentences, so "¿Cómo estás?" comes back as "Cómo estás?". The library puts it back from your text: ¿ ¡ « " ' “ ‘ ( [.

Subtitles

Errors

Exception When
InvalidArgumentException An empty text, an invalid pitch, rate or volume, or checkVoice() with an unknown voice
Afaya\EdgeTTS\Exception\EmptyAudioException The voice cannot read the text
Afaya\EdgeTTS\Exception\HandshakeException The service refused the connection; getStatusCode() has the HTTP status
Afaya\EdgeTTS\Exception\EdgeTTSException Any other error of the service or the network, such as "The service refused the request: Unsupported voice xx-XX-NobodyNeural."
RuntimeException Asking for audio or metadata before a synthesis

Every exception of the service extends EdgeTTSException, which extends RuntimeException.

A machine whose clock is off by more than a few minutes is refused by the service. The client then corrects its clock from the response and tries once more.

Upgrading

Version 1.7 stopped working when Microsoft moved the service to a new endpoint; 1.8.3 and later use the new one. What changed in each version, and what to look at when upgrading, is in the CHANGELOG.

Examples

Testing

The tests replay a recorded session of the service, through a fake and through a local server on real sockets, so they need no network.

License

GPL-3.0-or-later. See LICENSE.txt.

Acknowledgments


All versions of edge-tts with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
ext-openssl Version *
composer/ca-bundle Version ^1.3
symfony/console Version ^5.4|^6.0|^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package afaya/edge-tts contains the following files

Loading the files please wait ...