Open AI TTS (Text-to-Speech)

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIC. - Artificial Intelligence Command > ! Open AI TTS >

Open AI TTS (Text-to-Speech)

AIC.Say Text

Previous Top Next


MiniRobotLanguage (MRL)

 

AIC.Say Text

Converts text to spoken MP3 (in a file) and plays it back immediately.

 

 

Intention

 

The AIC.Say Text command is designed to convert text into an MP3 audio file using cloud services from Open AI and then Play this Audio-File back.

Technically this command is a combination of AIC.Text to MP3 and AIC.Play MP3 in one command.

This command requires an API key, which must be set using the AIC.Set Key command.

 

Hint: You can speak in many different languages. The model will automatically identify the written language and use the set parameters to generate speech in it.

 

 

The Caching System

There is a Caching System built into this command. Here's how it works and why it's beneficial:

 

In the observation of standard conversational patterns, it becomes evident that certain words and phrases are recurrently employed.

Given that the utilization of the Open AI Cloud incurs a cost, it is judicious to implement a caching mechanism.

When the Smart Package Robot identifies the repetition of specific words or phrases, it retrieves these elements from the cache rather than initiating a redundant request to the Open AI Cloud.

It should be noted that this caching feature is optional; specifying a filename will bypass the mechanism altogether.

 
The employment of a caching mechanism offers the distinct advantage of expedited language availability and of course lower cost,

compared to awaiting MP3 delivery from the Aopen AI Cloud.

However, it's important to acknowledge a minor drawback.

 

The Open AI Cloud is designed to never vocalize the exact same sentence in an identical manner. Consequently, bypassing the cache can lend a more authentic feel to the conversation.

On the other hand, repeated use of the cache may result in noticeable uniformity when the same sentence is audibly identical over time.

 

Ultimately, the choice of whether to utilize this feature rests with the user, allowing for customization based on individual preferences.

 

There is also a way to have the Smart Package Robot delete the actual recording and generate it new via Cloud.

If you do this:

 

AIC.Say Text|$$TXT|-

 

Then the Script will just re-generate the saved mp3-file with a new version, and save the new version in the Cache.

 

If P2 is omitted, the system will automatically generate a cache folder to store all MP3 files along with a checksum. This feature helps in reducing costs and saving resources by reusing the same MP3 file for repeated phrases.

Note: The system is case-sensitive, meaning the same phrase with different cases will generate different checksums. Be mindful of this when using the command.

This is intentional to keep compatibility with special Commands that may need upper and lowercase characters.

 

Efficiency and Speed: The built-in caching system serves multiple purposes, primarily aimed at optimizing resource usage and reducing costs.

When the same text is converted to MP3 multiple times, the system retrieves the already generated MP3 file from the cache instead of making a new API call to Open AI . This speeds up the process significantly.

Cost-Effectiveness: API calls usually come with a cost. By utilizing a caching system, you minimize the number of API calls made to Open AI , thereby saving money.

Resource Optimization: Generating an MP3 from text consumes computational resources. Caching allows the system to avoid redundant operations, thus saving CPU cycles and memory usage.

Customization and Control:The commands AIC.Set Folder and AIC.Get Folder allow you to specify the directory where the cached MP3 files and their checksums are stored. This gives you control over the organization of these files, making it easier to manage them.

Case Sensitivity:The system intentionally does not alter the case of the text when generating the checksum. This means that the same text with different casing will be treated as different phrases, each with its own cached MP3. This feature allows for precise control but also means you should be mindful of text casing to maximize the benefits of caching.

In summary, the built-in caching system is designed to make the command more efficient, cost-effective, and user-friendly.

 

The Location of the default cache folder is: "?exeloc\AIC_Folder\"

 

 

AIC.Set Key|<YourAPIKeyHere>

AIC.Say Text|Hello World|?path/to/save.mp3

     In this example, the text "Hello World" will be converted into an MP3 file and saved in the specified path. Then the command will Play back the MP3-File and SAY the Phrase.

 

 

Syntax

 

 

AIC.Say Text|P1[|P2]

AIC.Say|P1[|P2]

 

 

 

Parameter Explanation

 

P1: The text you want to convert into an MP3 file.

P2: Optional. The path where the generated MP3 file will be saved. The caching system will automatically be used if P2 is omitted or empty.

 

If P2 is omitted, the system will automatically generate a cache folder to store all MP3 files along with a checksum.

This feature helps in reducing costs and saving resources by reusing the same MP3 file for repeated phrases.

Note: The system is case-sensitive, meaning the same phrase with different cases will generate different checksums.

The use of different voices is not part of the caching, means the cache knows only the Text, not which voice it is.

To use the caching with different voices and cache them separately, you will need to Change the Cache Folder location using the AIC.Set Folder - Command.

 

 

Example

 

'***********************************

' AIC.-Sample

' Demonstration of speaking in many languages

'***********************************

MBX.We start with Windows native speaking

 

$$TXT=Hello, this is Sarah from Tech Support.

SAY.$$TXT|w

 

$$TXT=Hi Sarah, I'm having some issues with my computer.

SAY.$$TXT|w

 

$$TXT=Buenas tardes, soy Sarah del departamento de asistencia técnica.

SAY.$$TXT|w

 

$$TXT=Buenas tardes, Sarah. Mi ordenador no funciona bien; se bloquea todo el tiempo.

SAY.$$TXT|w

 

MBX.Now with the Elevenlabs Cloud Technology 

 

:new

AIC.Set Key|file

$$TXT=Hello, this is Sarah from Tech Support.

AIC.Say Text|$$TXT|-

 

$$TXT=Hi Sarah, I'm having some issues with my computer.

AIC.Say Text|$$TXT

 

$$TXT=Buenas tardes, soy Sarah del departamento de asistencia técnica.

AIC.Say Text|$$TXT

 

$$TXT=Buenas tardes, Sarah. Mi ordenador no funciona bien; se bloquea todo el tiempo.

AIC.Say Text|$$TXT

 

$$TXT=Bonjour, c'est Sarah du support technique.

AIC.Say Text|$$TXT

 

$$TXT=Bonjour Sarah, j'ai quelques problèmes avec mon ordinateur.

AIC.Say Text|$$TXT

 

$$TXT=Ciao, sono Sarah del supporto tecnico.

AIC.Say Text|$$TXT

 

$$TXT=Ciao Sarah, sto avendo alcuni problemi con il mio computer.

AIC.Say Text|$$TXT

 

$$TXT=Guten Tag, hier ist Sarah vom technischen Support.

AIC.Say Text|$$TXT

 

$$TXT=Guten Tag Sarah, wir haben einige Probleme mit dem Computer.

AIC.Say Text|$$TXT

 

MBX.!

ENR.

 

 

 

 

Remarks

 

The API key must be set using the AIC.Set Key command before using this command.

The system will use a cache to save resources only if P2 is omitted or empty.

 

 

Limitations:

 

-

 

 

See also: