Speech synthesis: Difference between revisions
(added omit from ML/I) |
m (→{{header|Wren}}: Minor tidy) |
||
(83 intermediate revisions by 49 users not shown) | |||
Line 1: | Line 1: | ||
{{task|Temporal media}} |
|||
{{task|Temporal media}}<!-- this task to be in "Temporal media" category once ready. -->[[Category:Speech synthesis]][[Category:Temporal media]] |
|||
<!-- this task to be in "Temporal media" category once ready. --> |
|||
Render the text “<tt>This is an example of speech synthesis.</tt>” as speech. |
|||
[[Category:Speech synthesis]] |
|||
[[Category:Temporal media]] |
|||
Render the text '''This is an example of speech synthesis''' as speech. |
|||
;Related task: |
|||
:* [[Using_a_Speech_engine_to_highlight_words|using a speech engine to highlight words]] |
|||
<br><br> |
|||
=={{header|11l}}== |
|||
{{trans|Nim}} |
|||
<syntaxhighlight lang="11l">os:(‘espeak 'Hello world!'’)</syntaxhighlight> |
|||
=={{header|AmigaBASIC}}== |
|||
<syntaxhighlight lang="amigabasic">text$=TRANSLATE$("This is an example of speech synthesis.") |
|||
SAY text$</syntaxhighlight> |
|||
=={{header|AppleScript}}== |
|||
Probably the only language where output to console is harder than output to a sound device. |
|||
<syntaxhighlight lang="applescript"> |
|||
say "This is an example of speech synthesis" |
|||
</syntaxhighlight> |
|||
=={{header|AutoHotkey}}== |
|||
{{works with|AutoHotkey_L}} |
|||
<syntaxhighlight lang="ahk">talk := ComObjCreate("sapi.spvoice") |
|||
talk.Speak("This is an example of speech synthesis.")</syntaxhighlight> |
|||
=={{header|AutoIt}}== |
|||
<syntaxhighlight lang="autoit">$voice = ObjCreate("SAPI.SpVoice") |
|||
$voice.Speak("This is an example of speech synthesis.")</syntaxhighlight> |
|||
=={{header|BASIC256}}== |
|||
<syntaxhighlight lang="basic256">say "Goodbye, World for the " + 123456 + "th time." |
|||
say "This is an example of speech synthesis."</syntaxhighlight> |
|||
=={{header|Batch File}}== |
|||
Sorry for cheating. This is Batch/JScript hybrid. |
|||
<syntaxhighlight lang="dos">@set @dummy=0 /* |
|||
::Batch File section |
|||
@echo off |
|||
cscript //e:jscript //nologo "%~f0" "%~1" |
|||
exit /b |
|||
::*/ |
|||
//The JScript section |
|||
var objVoice = new ActiveXObject("SAPI.SpVoice"); |
|||
objVoice.speak(WScript.Arguments(0));</syntaxhighlight> |
|||
{{Out}} |
|||
Saved as SPEAK.BAT |
|||
<pre>>SPEAK "This is an example of speech synthesis" |
|||
></pre> |
|||
=={{header|BBC BASIC}}== |
|||
{{works with|BBC BASIC for Windows}} |
|||
This calls the SAPI5 API directly, it does not need an external program. |
|||
<syntaxhighlight lang="bbcbasic"> SPF_ASYNC = 1 |
|||
ON ERROR SYS `CoUninitialize` : PRINT 'REPORT$ : END |
|||
ON CLOSE SYS `CoUninitialize` : QUIT |
|||
SYS "LoadLibrary","OLE32.DLL" TO O% |
|||
SYS "GetProcAddress",O%,"CoInitialize" TO `CoInitialize` |
|||
SYS "GetProcAddress",O%,"CoUninitialize" TO `CoUninitialize` |
|||
SYS "GetProcAddress",O%,"CoCreateInstance" TO `CoCreateInstance` |
|||
SYS `CoInitialize`,0 |
|||
voice% = FN_voice_create |
|||
PROC_voice_speak(voice%, "This is an example of speech synthesis") |
|||
PROC_voice_wait(voice%) |
|||
PROC_voice_free(voice%) |
|||
SYS `CoUninitialize` |
|||
END |
|||
DEF FN_voice_create |
|||
LOCAL C%, D%, F%, I%, M%, P%, V% |
|||
DIM C% LOCAL 15, I% LOCAL 15 |
|||
C%!0 = &96749377 : C%!4 = &11D23391 : C%!8 = &C000E39E : C%!12 = &9673794F |
|||
I%!0 = &6C44DF74 : I%!4 = &499272B9 : I%!8 = &99EFECA1 : I%!12 = &D422046E |
|||
SYS `CoCreateInstance`, C%, 0, 5, I%, ^V% |
|||
IF V%=0 ERROR 100, "SAPI5 not available" |
|||
= V% |
|||
DEF PROC_voice_speak(V%, M$) |
|||
DIM M% LOCAL 2*LENM$+1 |
|||
SYS "MultiByteToWideChar", 0, 0, M$, -1, M%, LENM$+1 |
|||
SYS !(!V%+80), V%, M%, SPF_ASYNC, 0 |
|||
ENDPROC |
|||
DEF PROC_voice_wait(V%) |
|||
SYS !(!V%+128), V% |
|||
ENDPROC |
|||
DEF PROC_voice_free(V%) |
|||
SYS !(!V%+8), V% |
|||
ENDPROC</syntaxhighlight> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
Following shining examples of <code>exec</code>ing external programs around here: |
Following shining examples of <code>exec</code>ing external programs around here: |
||
#include <sys/wait.h> |
|||
{{libheader|POSIX}} |
|||
int talk(char *s) |
|||
<syntaxhighlight lang="c">#include <sys/wait.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <unistd.h> |
|||
void talk(const char *s) |
|||
{ |
{ |
||
pid_t pid; |
|||
if (fork()) return wait(0); |
|||
int status; |
|||
execlp("espeak", s, (void*)0); |
|||
return -1; |
|||
pid = fork(); |
|||
if (pid < 0) { |
|||
perror("fork"); |
|||
exit(1); |
|||
} |
|||
if (pid == 0) { |
|||
execlp("espeak", "espeak", s, (void*)0); |
|||
perror("espeak"); |
|||
_exit(1); |
|||
} |
|||
waitpid(pid, &status, 0); |
|||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) |
|||
exit(1); |
|||
} |
} |
||
int main() |
int main() |
||
{ |
{ |
||
talk(" |
talk("This is an example of speech synthesis."); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
You need to 'Add Reference' to the COM "Microsoft Speech Object Library" in your Preferences. |
You need to 'Add Reference' to the COM "Microsoft Speech Object Library" in your Preferences. |
||
< |
<syntaxhighlight lang="csharp">using SpeechLib; |
||
namespace Speaking_Computer |
namespace Speaking_Computer |
||
Line 33: | Line 155: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header| |
=={{header|Clojure}}== |
||
{{libheader|facts/speech-synthesis}} |
|||
<syntaxhighlight lang="clojure">(use 'speech-synthesis.say) |
|||
(say "This is an example of speech synthesis.")</syntaxhighlight> |
|||
=={{header|FreeBASIC}}== |
|||
FreeBASIC does not have a native command for them. |
|||
We are going to invoke vbscript directly |
|||
<syntaxhighlight lang="freebasic">''This works on Windows. Does anyone know how it would be done in Linux? |
|||
Sub speak(texto As String) |
|||
Dim As String frase |
|||
frase ="mshta vbscript:Execute(""CreateObject(""""SAPI.SpVoice"""").Speak("""""+texto+""""")(window.close)"")" |
|||
Print texto |
|||
Shell frase |
|||
End Sub |
|||
speak "Vamos a contar " + str(123456) |
|||
speak "This is an example of speech synthesis." |
|||
Sleep</syntaxhighlight> |
|||
=={{header|FutureBasic}}== |
|||
FB offers easy access to excellent quality native synthesized voices in a variety of accents and languages available on Macs as demonstrated here. For a more comprehensive demonstration of speech synthesis, see the FutureBasic Rosetta Code task solution to: [[https://rosettacode.org/wiki/Old_lady_swallowed_a_fly#FutureBasic|FB's Old Laday Swallowed a Fly.]] |
|||
<syntaxhighlight lang="futurebasic"> |
|||
SpeechSynthesizerRef ref |
|||
ref = fn SpeechSynthesizerWithVoice( @"com.apple.speech.synthesis.voice.daniel.premium" ) |
|||
fn SpeechSynthesizerStartSpeakingString( ref, @"This is an example of speech synthesis." ) |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
=={{header|GlovePIE}}== |
|||
<syntaxhighlight lang="glovepie">if var.number=0 then |
|||
var.number=1 |
|||
say("This is an example of speech synthesis.") |
|||
endif</syntaxhighlight> |
|||
=={{header|Go}}== |
|||
Here's a library solution, but using a library written from scratch in Go. |
|||
<syntaxhighlight lang="go">package main |
|||
import ( |
|||
"go/build" |
|||
"log" |
|||
"path/filepath" |
|||
"github.com/unixpickle/gospeech" |
|||
"github.com/unixpickle/wav" |
|||
) |
|||
const pkgPath = "github.com/unixpickle/gospeech" |
|||
const input = "This is an example of speech synthesis." |
|||
func main() { |
|||
p, err := build.Import(pkgPath, ".", build.FindOnly) |
|||
if err != nil { |
|||
log.Fatal(err) |
|||
} |
|||
d := filepath.Join(p.Dir, "dict/cmudict-IPA.txt") |
|||
dict, err := gospeech.LoadDictionary(d) |
|||
if err != nil { |
|||
log.Fatal(err) |
|||
} |
|||
phonetics := dict.TranslateToIPA(input) |
|||
synthesized := gospeech.DefaultVoice.Synthesize(phonetics) |
|||
wav.WriteFile(synthesized, "output.wav") |
|||
}</syntaxhighlight> |
|||
=={{header|Groovy}}== |
|||
Mac only: |
|||
<syntaxhighlight lang="groovy">'say "This is an example of speech synthesis."'.execute()</syntaxhighlight> |
|||
=={{header|Haskell}}== |
|||
<syntaxhighlight lang="haskell"> |
|||
import System.Process (callProcess) -- From “process” library |
|||
say text = callProcess "espeak" ["--", text] |
|||
main = say "This is an example of speech synthesis." |
|||
</syntaxhighlight> |
|||
=={{header|JavaScript}}== |
|||
This should work in most major browsers |
|||
{{works with|Javascript}} |
|||
<syntaxhighlight lang="javascript"> |
|||
var utterance = new SpeechSynthesisUtterance("This is an example of speech synthesis."); |
|||
window.speechSynthesis.speak(utterance); |
|||
</syntaxhighlight> |
|||
Windows only: |
|||
{{works with|JScript}} |
|||
<syntaxhighlight lang="javascript">var voice = new ActiveXObject("SAPI.SpVoice"); |
|||
voice.speak("This is an example of speech synthesis.");</syntaxhighlight> |
|||
=={{header|Julia}}== |
|||
It seems that this and similar tasks can reduce to how the language can call an external program. Using the Julia REPL: |
|||
<syntaxhighlight lang="julia"> |
|||
julia> a = "hello world" |
|||
"hello world" |
|||
julia> run(`espeak $a`) |
|||
</syntaxhighlight> |
|||
=={{header|Kotlin}}== |
|||
{{trans|C}} |
|||
{{works with|Ubuntu 16.04}} |
|||
Note that this code does not work on Windows 10. |
|||
Note also that Kotlin Native does not support the automatic translation of C function-like macros such as WIFEXITED and WEXITSTATUS. |
|||
Whilst it is often possible to wrap such macros in 'ordinary' C functions and then expose the latter to Kotlin via a .klib, it is not worth the effort here. I have therefore confined myself to simply reporting a non-zero error status. |
|||
<syntaxhighlight lang="scala">// Kotlin Native v0.6.2 |
|||
import kotlinx.cinterop.* |
|||
import platform.posix.* |
|||
fun talk(s: String) { |
|||
val pid = fork() |
|||
if (pid < 0) { |
|||
perror("fork") |
|||
exit(1) |
|||
} |
|||
if (pid == 0) { |
|||
execlp("espeak", "espeak", s, null) |
|||
perror("espeak") |
|||
_exit(1) |
|||
} |
|||
memScoped { |
|||
val status = alloc<IntVar>() |
|||
waitpid(pid, status.ptr, 0) |
|||
if (status.value > 0) println("Exit status was ${status.value}") |
|||
} |
|||
} |
|||
fun main(args: Array<String>) { |
|||
talk("This is an example of speech synthesis.") |
|||
}</syntaxhighlight> |
|||
=={{header|Liberty BASIC}}== |
|||
Assumes that 'espeak' is available at the path shown. |
|||
<syntaxhighlight lang="lb"> |
|||
nomainwin |
|||
run "C:\Program Files\eSpeak\command_line\espeak "; chr$( 34); "This is an example of speech synthesis."; chr$( 34) |
|||
end |
|||
</syntaxhighlight> |
|||
Another dll has been posted to do the same job, at [http://basic.wikispaces.com/SpeechLibrary LB Community Wiki] |
|||
=={{header|Locomotive Basic}}== |
|||
Both hardware and software-only speech synthesizers exist for the CPC. A software-only solution, [http://www.cpc-power.com/index.php?page=detail&num=4372 Speech 1.1] by Superior Software (1986), supplies three BASIC extension commands (RSXes), "|say", "|speak", and "|pitch": |
|||
<syntaxhighlight lang="locobasic">|say,"This is an example of speech synthesis."</syntaxhighlight> |
|||
=={{header|M2000 Interpreter}}== |
|||
For Linux, through wine, if missing Sapi5 need this: winetricks speechsdk |
|||
===Using Statement Speech=== |
|||
<syntaxhighlight lang="m2000 interpreter"> |
|||
Module UsingStatementSpeech { |
|||
Volume 100 |
|||
Speech "This is an example of speech synthesis." |
|||
} |
|||
UsingStatementSpeech |
|||
</syntaxhighlight> |
|||
===Print each word as speak=== |
|||
<syntaxhighlight lang="m2000 interpreter"> |
|||
Module UsingEvents { |
|||
Declare WithEvents sp "SAPI.SpVoice" |
|||
That$="This is an example of speech synthesis." |
|||
EndStream=False |
|||
Function sp_Word { |
|||
Read New StreamNumber, StreamPosition, CharacterPosition, Length |
|||
Rem: Print StreamNumber, StreamPosition, CharacterPosition, Length |
|||
Print Mid$(That$, CharacterPosition+1, Length);" "; |
|||
Refresh |
|||
} |
|||
Function sp_EndStream { |
|||
Print |
|||
Refresh |
|||
EndStream=True |
|||
} |
|||
Const SVEStartInputStream = 2 |
|||
Const SVEEndInputStream = 4 |
|||
Const SVEVoiceChange = 8 |
|||
Const SVEBookmark = 16 |
|||
Const SVEWordBoundary = 32 |
|||
Const SVEPhoneme = 64 |
|||
Const SVESentenceBoundary = 128 |
|||
Const SVEViseme = 256 |
|||
Const SVEAudioLevel = 512 |
|||
Const SVEPrivate = 32768 |
|||
Const SVEAllEvents = 33790 |
|||
Const SVSFDefault = 0& |
|||
Const SVSFlagsAsync = 1& |
|||
Const SVSFPurgeBeforeSpeak=2& |
|||
With sp, "EventInterests", SVEWordBoundary+SVEEndInputStream |
|||
Method sp, "Speak", That$, SVSFlagsAsync |
|||
While Not EndStream {Wait 10} |
|||
} |
|||
UsingEvents |
|||
</syntaxhighlight> |
|||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
|||
<syntaxhighlight lang="mathematica">Speak["This is an example of speech synthesis."]</syntaxhighlight> |
|||
=={{header|Nim}}== |
|||
Using same method as Julia. |
|||
<syntaxhighlight lang="nim">import osproc |
|||
discard execCmd("espeak 'Hello world!'")</syntaxhighlight> |
|||
=={{header|PARI/GP}}== |
|||
Define a function that is using espeak package from Linux. |
|||
<syntaxhighlight lang="parigp">speak(txt,opt="")=extern(concat(["espeak ",opt," \"",txt,"\""]));</syntaxhighlight> |
|||
Now let it speak: |
|||
<syntaxhighlight lang="parigp">speak("This is an example of speech synthesis")</syntaxhighlight> |
|||
A monster speech tongue-twister: |
|||
<syntaxhighlight lang="parigp">speak("The seething sea ceaseth and thus the seething sea sufficeth us.","-p10 -s100")</syntaxhighlight> |
|||
A foreign language "Zungenbrecher": |
|||
<syntaxhighlight lang="parigp">speak("Fischers Fritz fischt frische Fische.","-vmb/mb-de2 -s130")</syntaxhighlight> |
|||
=={{header|Perl}}== |
|||
<syntaxhighlight lang="perl">use Speech::Synthesis; |
|||
($engine) = Speech::Synthesis->InstalledEngines(); |
|||
($voice) = Speech::Synthesis->InstalledVoices(engine => $engine); |
|||
Speech::Synthesis |
|||
->new(engine => $engine, voice => $voice->{id}) |
|||
->speak("This is an example of speech synthesis.");</syntaxhighlight> |
|||
=={{header|Phix}}== |
|||
{{libheader|Phix/pGUI}} |
|||
{{libheader|Phix/online}} |
|||
You can run this online [http://phix.x10.mx/p2js/Speak.htm here]. |
|||
<!--<syntaxhighlight lang="phix">(phixonline)--> |
|||
<span style="color: #000080;font-style:italic;">-- |
|||
-- demo\rosetta\Speak.exw |
|||
-- ====================== |
|||
--</span> |
|||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
|||
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #000000;">6</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- WINDOWS or JS, not LINUX</span> |
|||
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #000000;">32</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- Windows 32 bit only, for now... |
|||
-- (^ runs fine on a 64-bit OS, but needs a 32-bit p.exe)</span> |
|||
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.2"</span><span style="color: #0000FF;">)</span> |
|||
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #7060A8;">speak</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> <span style="color: #000080;font-style:italic;">-- (new in 1.0.2)</span> |
|||
<span style="color: #008080;">constant</span> <span style="color: #000000;">text</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"This is an example of speech synthesis"</span> |
|||
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
|||
<span style="color: #008080;">function</span> <span style="color: #000000;">button_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000080;font-style:italic;">/*ih*/</span><span style="color: #0000FF;">)</span> |
|||
<span style="color: #7060A8;">speak</span><span style="color: #0000FF;">(</span><span style="color: #000000;">text</span><span style="color: #0000FF;">)</span> |
|||
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_CONTINUE</span> |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span> |
|||
<span style="color: #7060A8;">IupOpen</span><span style="color: #0000FF;">()</span> |
|||
<span style="color: #004080;">Ihandle</span> <span style="color: #000000;">btn</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupButton</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Speak"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"button_cb"</span><span style="color: #0000FF;">)),</span> |
|||
<span style="color: #000000;">dlg</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupDialog</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">IupHbox</span><span style="color: #0000FF;">({</span><span style="color: #000000;">btn</span><span style="color: #0000FF;">},</span><span style="color: #008000;">"MARGIN=180x80"</span><span style="color: #0000FF;">))</span> |
|||
<span style="color: #7060A8;">IupSetAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dlg</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"TITLE"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">text</span><span style="color: #0000FF;">)</span> |
|||
<span style="color: #7060A8;">IupShow</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dlg</span><span style="color: #0000FF;">)</span> |
|||
<span style="color: #008080;">if</span> <span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()!=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">then</span> |
|||
<span style="color: #7060A8;">IupMainLoop</span><span style="color: #0000FF;">()</span> |
|||
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
|||
<!--</syntaxhighlight>--> |
|||
Note that speech synthesis has refused to operate in a browser without user activation since 2018, hence the tiny GUI with a button.<br> |
|||
Should you for some strange reason want it on desktop/Phix without any GUI, you'd need to arrange for COM initialisation etc yourself. |
|||
=={{header|PHP}}== |
|||
Linux & Mac example uses eSpeak (eSpeak Instillation instructions included in comments). |
|||
Mac also has a built in Speech synthesis system and this example allows you to optionally use that instead of eSpeak. |
|||
Windows example uses built in Windows Speech API. |
|||
{{works with|Mac OS & Linux OS}} |
|||
<syntaxhighlight lang="php"> |
|||
<?php |
|||
<?php |
|||
/* |
|||
_ _____ _ _ _ ___ __ |
|||
| | |_ _| \ | | | | \ \ / / |
|||
| | | | | \| | | | |\ V / |
|||
| | | | | . ` | | | | > < |
|||
| |____ _| |_| |\ | |__| |/ . \ |
|||
|______|_____|_| \_|\____//_/ \_\ |
|||
*/ |
|||
// Install eSpeak - Run this command in a terminal |
|||
/* |
|||
sudo apt-get install eSpeak |
|||
*/ |
|||
/* |
|||
__ __ _____ |
|||
| \/ | /\ / ____| |
|||
| \ / | / \ | | |
|||
| |\/| | / /\ \| | |
|||
| | | |/ ____ \ |____ |
|||
|_| |_/_/ \_\_____| |
|||
*/ |
|||
// Mac has it's own Speech Synthesis system |
|||
// accessible via the "say" command. |
|||
// To use eSpeak on a Mac, change this variable to true. |
|||
$mac_use_espeak = false; |
|||
// To use eSpeak on a Mac you need to install |
|||
// Homebrew Package Manager & eSpeak |
|||
// Run these commands in a terminal: |
|||
/* |
|||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
|||
brew install espeak |
|||
*/ |
|||
$voice = "espeak"; |
|||
$statement = 'Hello World!'; |
|||
$save_file_args = '-w HelloWorld.wav'; // eSpeak args |
|||
// Ask PHP what OS it was compiled for, |
|||
// CAPITALIZE it and truncate to the first 3 chars. |
|||
$OS = strtoupper(substr(PHP_OS, 0, 3)); |
|||
// If this is Darwin (MacOS) AND we don't want eSpeak |
|||
elseif($OS === 'DAR' && $mac_use_espeak == false) { |
|||
$voice = "say -v 'Victoria'"; |
|||
$save_file_args = '-o HelloWorld.wav'; // say args |
|||
} |
|||
// Say It |
|||
exec("$voice '$statement'"); |
|||
// Save it to a File |
|||
exec("$voice '$statement' $save_file_args"); |
|||
</syntaxhighlight> |
|||
{{works with|Windows OS}} |
|||
<syntaxhighlight lang="php"> |
|||
<?php |
|||
// List available SAPI voices |
|||
// 0 = Microsoft David Desktop - English (United States) |
|||
// 1 = Microsoft Zira Desktop - English (United States) |
|||
// ... If you have additional voices installed |
|||
function ListSAPIVoices(&$voice){ |
|||
foreach($voice->GetVoices as $v){ |
|||
echo $v->GetDescription . PHP_EOL; |
|||
} |
|||
} |
|||
$filename = "DaisyBell.wav"; |
|||
// https://en.wikipedia.org/wiki/Daisy_Bell#Computing_and_technology |
|||
// "In 1961, an IBM 704 at Bell Labs was programmed to sing "Daisy Bell"- |
|||
// in the earliest demonstration of computer speech synthesis." |
|||
$statement = "There is a flower within my heart, Daisy, Daisy! |
|||
Planted one day by a glancing dart, |
|||
Planted by Daisy Bell! |
|||
Whether she loves me or loves me not, |
|||
Sometimes it's hard to tell; |
|||
Yet I am longing to share the lot |
|||
Of beautiful Daisy Bell! |
|||
Daisy, Daisy, |
|||
Give me your answer, do! |
|||
I'm half crazy, |
|||
All for the love of you! |
|||
It won't be a stylish marriage, |
|||
I can't afford a carriage, |
|||
But you'll look sweet on the seat |
|||
Of a bicycle built for two! |
|||
We will go tandem as man and wife, Daisy, Daisy! |
|||
Ped'ling away down the road of life, I and my Daisy Bell! |
|||
When the road's dark we can both despise Po'leaseman and lamps as well; |
|||
There are bright lights in the dazzling eyes Of beautiful Daisy Bell! |
|||
Daisy, Daisy, |
|||
Give me your answer, do! |
|||
I'm half crazy, |
|||
All for the love of you! |
|||
It won't be a stylish marriage, |
|||
I can't afford a carriage, |
|||
But you'll look sweet on the seat |
|||
Of a bicycle built for two! |
|||
I will stand by you in wheel or woe, Daisy, Daisy! |
|||
You'll be the bell which I'll ring you know! Sweet little Daisy Bell! |
|||
You'll take the lead in each trip we take, Then if I don't do well; |
|||
I will permit you to use the brake, My beautiful Daisy Bell!"; |
|||
// COM (Component Object Model) objects |
|||
// https://www.php.net/manual/en/book.com.php |
|||
$voice = new COM("SAPI.SpVoice"); |
|||
$voice_file_stream = new COM("SAPI.SpVoice"); |
|||
$file_stream = new COM("SAPI.SpFileStream"); |
|||
// Change $voice to Zira |
|||
$voice->Voice = $voice->GetVoices()->Item(1); |
|||
// Change $voice_file_stream to David |
|||
$voice_file_stream->Voice = $voice_file_stream->GetVoices()->Item(0); |
|||
// Have voices announce themselves |
|||
//$voice->Speak($voice->Voice->GetDescription); // (Zira) |
|||
//$voice_file_stream->Speak($voice_file_stream->Voice->GetDescription); // (David) |
|||
/* |
|||
Select Stream Quality: |
|||
11kHz 8Bit Mono = 8 |
|||
11kHz 8Bit Stereo = 9 |
|||
11kHz 16Bit Mono = 10 |
|||
11kHz 16Bit Stereo = 11 |
|||
... |
|||
16kHz 8Bit Mono = 16 |
|||
16kHz 8Bit Stereo = 17 |
|||
16kHz 16Bit Mono = 18; |
|||
16kHz 16Bit Stereo = 19 |
|||
... |
|||
32kHz 8Bit Mono = 28 |
|||
32kHz 8Bit Stereo = 29 |
|||
32kHz 16Bit Mono = 30 |
|||
32kHz 16Bit Stereo = 31 |
|||
... |
|||
*/ |
|||
// Set stream quality |
|||
$file_stream->Format->Type = 17; // 16kHz 8Bit Stereo |
|||
/* |
|||
Select Speech StreamFile Mode: |
|||
Read = 0 |
|||
ReadWrite = 1 |
|||
Create = 2 |
|||
CreateForWrite = 3 |
|||
*/ |
|||
$mode = 3; |
|||
// Have $voice (Zira) announce beginning file stream |
|||
$voice->Speak('Opening audio file stream'); |
|||
// Output TTS to File |
|||
$file_stream->Open($filename, $mode); // Open stream and create file |
|||
$voice_file_stream->AudioOutputStream = $file_stream; // Begin streaming TTS |
|||
// Have $voice_file_stream (David) speak $statement |
|||
$voice_file_stream->Speak($statement); |
|||
$file_stream->Close; // Close stream |
|||
// Have $voice (Zira) announce file stream completion |
|||
$voice->Speak('File stream complete'); |
|||
</syntaxhighlight> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
< |
<syntaxhighlight lang="picolisp">(call 'espeak "This is an example of speech synthesis.")</syntaxhighlight> |
||
=={{header|PowerShell}}== |
|||
<syntaxhighlight lang="powershell"> |
|||
Add-Type -AssemblyName System.Speech |
|||
$anna = New-Object System.Speech.Synthesis.SpeechSynthesizer |
|||
$anna.Speak("I'm sorry Dave, I'm afraid I can't do that.") |
|||
$anna.Dispose() |
|||
</syntaxhighlight> |
|||
=={{header|Python}}== |
|||
<syntaxhighlight lang="python"> |
|||
import pyttsx |
|||
engine = pyttsx.init() |
|||
engine.say("It was all a dream.") |
|||
engine.runAndWait() |
|||
</syntaxhighlight> |
|||
=={{header|Quackery}}== |
|||
Mac specific. |
|||
<syntaxhighlight lang="Quackery"> [ $ / |
|||
import subprocess |
|||
subprocess.run(["say", |
|||
string_from_stack()]) |
|||
/ python ] is speak ( $ --> ) |
|||
$ "This is an example of speech synthesis" speak</syntaxhighlight> |
|||
=={{header|Racket}}== |
|||
Should work on all platforms. |
|||
<syntaxhighlight lang="racket"> |
|||
#lang racket |
|||
(require racket/lazy-require) |
|||
(lazy-require [ffi/com (com-create-instance com-release com-invoke)]) |
|||
(define (speak text) |
|||
(cond [(eq? 'windows (system-type)) |
|||
(define c (com-create-instance "SAPI.SpVoice")) |
|||
(com-invoke c "Speak" text) |
|||
(com-release c)] |
|||
[(ormap find-executable-path '("say" "espeak")) |
|||
=> (λ(exe) (void (system* exe text)))] |
|||
[else (error 'speak "I'm speechless!")])) |
|||
(speak "This is an example of speech synthesis.") |
|||
</syntaxhighlight> |
|||
=={{header|Raku}}== |
|||
(formerly Perl 6) |
|||
<syntaxhighlight lang="raku" line>run 'espeak', 'This is an example of speech synthesis.';</syntaxhighlight> |
|||
=={{header|REXX}}== |
|||
{{works with|Windowx/XP or later}} |
|||
Programming note: This REXX program uses a freeware program NIRCMD to interface with the Microsoft Windows speech synthesizer program '''SAM''', a text to speech using a male voice. SAM can possibly be configured to use other voices with later releases of Windows. More recent Microsoft Windows have another speech synthesizer program: ANNA. |
|||
<syntaxhighlight lang="rexx">/*REXX program uses a command line interface to invoke Windows SAM for speech synthesis.*/ |
|||
parse arg t /*get the (optional) text from the C.L.*/ |
|||
if t='' then exit /*Nothing to say? Then exit program.*/ |
|||
dquote= '"' |
|||
rate= 1 /*talk: -10 (slow) to 10 (fast). */ |
|||
/* [↓] where the rubber meets the road*/ |
|||
'NIRCMD' "speak text" dquote t dquote rate /*NIRCMD invokes Microsoft's Sam voice*/ |
|||
/*stick a fork in it, we're all done. */</syntaxhighlight> |
|||
Note: The name of the above REXX program is '''speak.rex'''<br> |
|||
'''usage''' using the command: |
|||
<pre> |
|||
speak This is an example of speech synthesis. |
|||
</pre> |
|||
=={{header|Ring}}== |
|||
<syntaxhighlight lang="ring"> |
|||
load "guilib.ring" |
|||
myApp = New qApp |
|||
{ |
|||
Text = "Hello. This is an example of speech synthesis" |
|||
voice = new QTextToSpeech(null) |
|||
voice.Say(Text) |
|||
exec() |
|||
} |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
"Hello. This is an example of speech synthesis" |
|||
</pre> |
|||
=={{header|Ring}}== |
|||
<syntaxhighlight lang="ring"> |
|||
load "guilib.ring" |
|||
load "stdlib.ring" |
|||
MyApp = New qApp { |
|||
win1 = new qWidget() { |
|||
setwindowtitle("Hello World") |
|||
setGeometry(100,100,370,250) |
|||
Text = "This is an example of speech synthesis" |
|||
Text = split(Text," ") |
|||
label1 = new qLabel(win1) { |
|||
settext("What is your name ?") |
|||
setGeometry(10,20,350,30) |
|||
setalignment(Qt_AlignHCenter) |
|||
} |
|||
btn1 = new qpushbutton(win1) { |
|||
setGeometry(10,200,100,30) |
|||
settext("Say Hello") |
|||
setclickevent("pHello()") |
|||
} |
|||
btn2 = new qpushbutton(win1) { |
|||
setGeometry(150,200,100,30) |
|||
settext("Close") |
|||
setclickevent("pClose()") |
|||
} |
|||
lineedit1 = new qlineedit(win1) { |
|||
setGeometry(10,100,350,30) |
|||
} |
|||
voice = new QTextToSpeech(win1) { |
|||
} |
|||
show() |
|||
} |
|||
exec() |
|||
} |
|||
Func pHello |
|||
lineedit1.settext( "Hello " + lineedit1.text()) |
|||
for n = 1 to len(Text) |
|||
voice.Say(Text[n]) |
|||
see Text[n] + nl |
|||
next |
|||
Func pClose |
|||
MyApp.quit() |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
This |
|||
is |
|||
an |
|||
example |
|||
of |
|||
speech |
|||
synthesis |
|||
</pre> |
|||
=={{header|Ruby}}== |
|||
Using this module to encapsulate operating system lookup |
|||
<syntaxhighlight lang="ruby">module OperatingSystem |
|||
require 'rbconfig' |
|||
module_function |
|||
def operating_system |
|||
case RbConfig::CONFIG["host_os"] |
|||
when /linux/i |
|||
:linux |
|||
when /cygwin|mswin|mingw|windows/i |
|||
:windows |
|||
when /darwin/i |
|||
:mac |
|||
when /solaris/i |
|||
:solaris |
|||
else |
|||
nil |
|||
end |
|||
end |
|||
def linux?; operating_system == :linux; end |
|||
def windows?; operating_system == :windows; end |
|||
def mac?; operating_system == :mac; end |
|||
end</syntaxhighlight> |
|||
{{libheader|win32-utils}} |
|||
{{works with|Ruby|1.9}} |
|||
Uses <code>espeak</code> on Linux, <code>say</code> on Mac, and the win32 SAPI library on Windows. |
|||
<syntaxhighlight lang="ruby">load 'operating_system.rb' |
|||
def speak(text) |
|||
if OperatingSystem.windows? |
|||
require 'win32/sapi5' |
|||
v = Win32::SpVoice.new |
|||
v.Speak(text) |
|||
elsif OperatingSystem.mac? |
|||
IO.popen(["say"], "w") {|pipe| pipe.puts text} |
|||
else |
|||
# Try to run "espeak". No OperatingSystem check: "espeak" is |
|||
# for Linux but is also an optional package for BSD. |
|||
IO.popen(["espeak", "-stdin"], "w") {|pipe| pipe.puts text} |
|||
end |
|||
end |
|||
speak 'This is an example of speech synthesis.'</syntaxhighlight> |
|||
=={{header|Scala}}== |
|||
{{libheader|FreeTTS|1.2}} |
|||
<syntaxhighlight lang="scala">import javax.speech.Central |
|||
import javax.speech.synthesis.{Synthesizer, SynthesizerModeDesc} |
|||
object ScalaSpeaker extends App { |
|||
def speech(text: String) = { |
|||
if (!text.trim.isEmpty) { |
|||
val VOICENAME = "kevin16" |
|||
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory") |
|||
Central.registerEngineCentral("com.sun.speech.freetts.jsapi.FreeTTSEngineCentral") |
|||
val synth = Central.createSynthesizer(null) |
|||
synth.allocate() |
|||
val desc = synth.getEngineModeDesc match {case g2: SynthesizerModeDesc => g2} |
|||
synth.getSynthesizerProperties.setVoice(desc.getVoices.find(_.toString == VOICENAME).get) |
|||
synth.speakPlainText(text, null) |
|||
synth.waitEngineState(Synthesizer.QUEUE_EMPTY) |
|||
synth.deallocate() |
|||
} |
|||
} |
|||
speech( """Thinking of Holland |
|||
|I see broad rivers |
|||
|slowly chuntering |
|||
|through endless lowlands, |
|||
|rows of implausibly |
|||
|airy poplars |
|||
|standing like tall plumes |
|||
|against the horizon; |
|||
|and sunk in the unbounded |
|||
|vastness of space |
|||
|homesteads and boweries |
|||
|dotted across the land, |
|||
|copses, villages, |
|||
|couchant towers, |
|||
|churches and elm-trees, |
|||
|bound in one great unity. |
|||
|There the sky hangs low, |
|||
|and steadily the sun |
|||
|is smothered in a greyly |
|||
|iridescent smirr, |
|||
|and in every province |
|||
|the voice of water |
|||
|with its lapping disasters |
|||
|is feared and hearkened.""".stripMargin) |
|||
}</syntaxhighlight> |
|||
=={{header|Sidef}}== |
|||
<syntaxhighlight lang="ruby">func text2speech(text, lang='en') { |
|||
Sys.run("espeak -v #{lang} -w /dev/stdout #{text.escape} | aplay"); |
|||
} |
|||
text2speech("This is an example of speech synthesis.");</syntaxhighlight> |
|||
=={{header|Swift}}== |
|||
OS X comes with a program called "say," that does speech. |
|||
<syntaxhighlight lang="swift">import Foundation |
|||
let task = NSTask() |
|||
task.launchPath = "/usr/bin/say" |
|||
task.arguments = ["This is an example of speech synthesis."] |
|||
task.launch()</syntaxhighlight> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
This just passes the string into the Festival system: |
This just passes the string into the Festival system: |
||
< |
<syntaxhighlight lang="tcl">exec festival --tts << "This is an example of speech synthesis."</syntaxhighlight> |
||
Alternatively, on MacOS X, you'd use the system <code>say</code> program: |
Alternatively, on MacOS X, you'd use the system <code>say</code> program: |
||
< |
<syntaxhighlight lang="tcl">exec say << "This is an example of speech synthesis."</syntaxhighlight> |
||
On Windows, there is a service available by COM for speech synthesis: |
On Windows, there is a service available by COM for speech synthesis: |
||
{{libheader|tcom}} |
{{libheader|tcom}} |
||
< |
<syntaxhighlight lang="tcl">package require tcom |
||
set msg "This is an example of speech synthesis." |
set msg "This is an example of speech synthesis." |
||
set voice [::tcom::ref createobject Sapi.SpVoice] |
set voice [::tcom::ref createobject Sapi.SpVoice] |
||
$voice Speak $msg 0</ |
$voice Speak $msg 0</syntaxhighlight> |
||
Putting these together into a helper procedure, we get: |
Putting these together into a helper procedure, we get: |
||
< |
<syntaxhighlight lang="tcl">proc speak {msg} { |
||
global tcl_platform |
global tcl_platform |
||
if {$tcl_platform(platform) eq "windows"} { |
if {$tcl_platform(platform) eq "windows"} { |
||
Line 67: | Line 936: | ||
} |
} |
||
} |
} |
||
speak "This is an example of speech synthesis."</ |
speak "This is an example of speech synthesis."</syntaxhighlight> |
||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
Line 73: | Line 942: | ||
{{works with|Bourne Shell}} {{works with|bash}} |
{{works with|Bourne Shell}} {{works with|bash}} |
||
< |
<syntaxhighlight lang="bash">#!/bin/sh |
||
espeak "This is an example of speech synthesis."</ |
espeak "This is an example of speech synthesis."</syntaxhighlight> |
||
=={{header| |
=={{header|VBScript}}== |
||
<syntaxhighlight lang="vbs"> |
|||
Dim message, sapi |
|||
message = "This is an example of speech synthesis." |
|||
Set sapi = CreateObject("sapi.spvoice") |
|||
sapi.Speak message |
|||
</syntaxhighlight> |
|||
=={{header|Wren}}== |
|||
This example makes use of the Currah Speech Synthesizer peripheral device. |
|||
The ability to call external processes such as ''espeak'' is expected to be added to Wren-cli in the next release. In the meantime, we embed the following Wren script in a minimal C host (no error checking) to complete this task. |
|||
<syntaxhighlight lang="wren">/* Speech_synthesis.wren */ |
|||
class C { |
|||
<lang zx basic>10 LET s$="(th)is is an exampul of sp(ee)(ch) sin(th)esis":PAUSE 1</lang> |
|||
foreign static getInput(maxSize) |
|||
foreign static espeak(s) |
|||
} |
|||
System.write("Enter something to say (up to 100 characters) : ") |
|||
var s = C.getInput(100) |
|||
C.espeak(s)</syntaxhighlight> |
|||
<br> |
|||
We now embed this in the following C program, compile and run it. |
|||
<syntaxhighlight lang="c">/* gcc Speech_synthesis.c -o Speech_synthesis -lwren -lm */ |
|||
#include <stdio.h> |
|||
#include <stdio_ext.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
#include "wren.h" |
|||
void C_getInput(WrenVM* vm) { |
|||
int maxSize = (int)wrenGetSlotDouble(vm, 1) + 2; |
|||
char input[maxSize]; |
|||
fgets(input, maxSize, stdin); |
|||
__fpurge(stdin); |
|||
input[strcspn(input, "\n")] = 0; |
|||
wrenSetSlotString(vm, 0, (const char*)input); |
|||
} |
|||
void C_espeak(WrenVM* vm) { |
|||
const char *arg = wrenGetSlotString(vm, 1); |
|||
char command[strlen(arg) + 10]; |
|||
strcpy(command, "espeak \""); |
|||
strcat(command, arg); |
|||
strcat(command, "\""); |
|||
system(command); |
|||
} |
|||
WrenForeignMethodFn bindForeignMethod( |
|||
WrenVM* vm, |
|||
const char* module, |
|||
const char* className, |
|||
bool isStatic, |
|||
const char* signature) { |
|||
if (strcmp(module, "main") == 0) { |
|||
if (strcmp(className, "C") == 0) { |
|||
if (isStatic && strcmp(signature, "getInput(_)") == 0) return C_getInput; |
|||
if (isStatic && strcmp(signature, "espeak(_)") == 0) return C_espeak; |
|||
} |
|||
} |
|||
return NULL; |
|||
} |
|||
static void writeFn(WrenVM* vm, const char* text) { |
|||
printf("%s", text); |
|||
} |
|||
char *readFile(const char *fileName) { |
|||
FILE *f = fopen(fileName, "r"); |
|||
fseek(f, 0, SEEK_END); |
|||
long fsize = ftell(f); |
|||
rewind(f); |
|||
char *script = malloc(fsize + 1); |
|||
fread(script, 1, fsize, f); |
|||
fclose(f); |
|||
script[fsize] = 0; |
|||
return script; |
|||
} |
|||
int main(int argc, char **argv) { |
|||
WrenConfiguration config; |
|||
wrenInitConfiguration(&config); |
|||
config.writeFn = &writeFn; |
|||
config.bindForeignMethodFn = &bindForeignMethod; |
|||
WrenVM* vm = wrenNewVM(&config); |
|||
const char* module = "main"; |
|||
const char* fileName = "Speech_synthesis.wren"; |
|||
char *script = readFile(fileName); |
|||
wrenInterpret(vm, module, script); |
|||
wrenFreeVM(vm); |
|||
free(script); |
|||
return 0; |
|||
}</syntaxhighlight> |
|||
=={{header|Zoomscript}}== |
|||
For typing: |
|||
<syntaxhighlight lang="zoomscript">speak "This is an example of speech synthesis."</syntaxhighlight> |
|||
For importing: |
|||
¶0¶speak "This is an example of speech synthesis." |
|||
=={{header|ZX Spectrum Basic}}== |
|||
This example makes use of the Currah Speech Synthesizer peripheral device. |
|||
<syntaxhighlight lang="zx basic">10 LET s$="(th)is is an exampul of sp(ee)(ch) sin(th)esis":PAUSE 1</syntaxhighlight> |
|||
{{omit from|TI-83 BASIC}} |
|||
{{omit from|Maxima}} |
|||
{{omit from|ML/I}} |
{{omit from|ML/I}} |
||
{{omit from|zkl}} |
Latest revision as of 15:38, 9 February 2024
You are encouraged to solve this task according to the task description, using any language you may know.
Render the text This is an example of speech synthesis as speech.
- Related task
11l
os:(‘espeak 'Hello world!'’)
AmigaBASIC
text$=TRANSLATE$("This is an example of speech synthesis.")
SAY text$
AppleScript
Probably the only language where output to console is harder than output to a sound device.
say "This is an example of speech synthesis"
AutoHotkey
talk := ComObjCreate("sapi.spvoice")
talk.Speak("This is an example of speech synthesis.")
AutoIt
$voice = ObjCreate("SAPI.SpVoice")
$voice.Speak("This is an example of speech synthesis.")
BASIC256
say "Goodbye, World for the " + 123456 + "th time."
say "This is an example of speech synthesis."
Batch File
Sorry for cheating. This is Batch/JScript hybrid.
@set @dummy=0 /*
::Batch File section
@echo off
cscript //e:jscript //nologo "%~f0" "%~1"
exit /b
::*/
//The JScript section
var objVoice = new ActiveXObject("SAPI.SpVoice");
objVoice.speak(WScript.Arguments(0));
- Output:
Saved as SPEAK.BAT
>SPEAK "This is an example of speech synthesis" >
BBC BASIC
This calls the SAPI5 API directly, it does not need an external program.
SPF_ASYNC = 1
ON ERROR SYS `CoUninitialize` : PRINT 'REPORT$ : END
ON CLOSE SYS `CoUninitialize` : QUIT
SYS "LoadLibrary","OLE32.DLL" TO O%
SYS "GetProcAddress",O%,"CoInitialize" TO `CoInitialize`
SYS "GetProcAddress",O%,"CoUninitialize" TO `CoUninitialize`
SYS "GetProcAddress",O%,"CoCreateInstance" TO `CoCreateInstance`
SYS `CoInitialize`,0
voice% = FN_voice_create
PROC_voice_speak(voice%, "This is an example of speech synthesis")
PROC_voice_wait(voice%)
PROC_voice_free(voice%)
SYS `CoUninitialize`
END
DEF FN_voice_create
LOCAL C%, D%, F%, I%, M%, P%, V%
DIM C% LOCAL 15, I% LOCAL 15
C%!0 = &96749377 : C%!4 = &11D23391 : C%!8 = &C000E39E : C%!12 = &9673794F
I%!0 = &6C44DF74 : I%!4 = &499272B9 : I%!8 = &99EFECA1 : I%!12 = &D422046E
SYS `CoCreateInstance`, C%, 0, 5, I%, ^V%
IF V%=0 ERROR 100, "SAPI5 not available"
= V%
DEF PROC_voice_speak(V%, M$)
DIM M% LOCAL 2*LENM$+1
SYS "MultiByteToWideChar", 0, 0, M$, -1, M%, LENM$+1
SYS !(!V%+80), V%, M%, SPF_ASYNC, 0
ENDPROC
DEF PROC_voice_wait(V%)
SYS !(!V%+128), V%
ENDPROC
DEF PROC_voice_free(V%)
SYS !(!V%+8), V%
ENDPROC
C
Following shining examples of exec
ing external programs around here:
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void talk(const char *s)
{
pid_t pid;
int status;
pid = fork();
if (pid < 0) {
perror("fork");
exit(1);
}
if (pid == 0) {
execlp("espeak", "espeak", s, (void*)0);
perror("espeak");
_exit(1);
}
waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
exit(1);
}
int main()
{
talk("This is an example of speech synthesis.");
return 0;
}
C#
You need to 'Add Reference' to the COM "Microsoft Speech Object Library" in your Preferences.
using SpeechLib;
namespace Speaking_Computer
{
public class Program
{
private static void Main()
{
var voice = new SpVoice();
voice.Speak("This is an example of speech synthesis.");
}
}
}
Clojure
(use 'speech-synthesis.say)
(say "This is an example of speech synthesis.")
FreeBASIC
FreeBASIC does not have a native command for them.
We are going to invoke vbscript directly
''This works on Windows. Does anyone know how it would be done in Linux?
Sub speak(texto As String)
Dim As String frase
frase ="mshta vbscript:Execute(""CreateObject(""""SAPI.SpVoice"""").Speak("""""+texto+""""")(window.close)"")"
Print texto
Shell frase
End Sub
speak "Vamos a contar " + str(123456)
speak "This is an example of speech synthesis."
Sleep
FutureBasic
FB offers easy access to excellent quality native synthesized voices in a variety of accents and languages available on Macs as demonstrated here. For a more comprehensive demonstration of speech synthesis, see the FutureBasic Rosetta Code task solution to: [Old Laday Swallowed a Fly.]
SpeechSynthesizerRef ref
ref = fn SpeechSynthesizerWithVoice( @"com.apple.speech.synthesis.voice.daniel.premium" )
fn SpeechSynthesizerStartSpeakingString( ref, @"This is an example of speech synthesis." )
HandleEvents
GlovePIE
if var.number=0 then
var.number=1
say("This is an example of speech synthesis.")
endif
Go
Here's a library solution, but using a library written from scratch in Go.
package main
import (
"go/build"
"log"
"path/filepath"
"github.com/unixpickle/gospeech"
"github.com/unixpickle/wav"
)
const pkgPath = "github.com/unixpickle/gospeech"
const input = "This is an example of speech synthesis."
func main() {
p, err := build.Import(pkgPath, ".", build.FindOnly)
if err != nil {
log.Fatal(err)
}
d := filepath.Join(p.Dir, "dict/cmudict-IPA.txt")
dict, err := gospeech.LoadDictionary(d)
if err != nil {
log.Fatal(err)
}
phonetics := dict.TranslateToIPA(input)
synthesized := gospeech.DefaultVoice.Synthesize(phonetics)
wav.WriteFile(synthesized, "output.wav")
}
Groovy
Mac only:
'say "This is an example of speech synthesis."'.execute()
Haskell
import System.Process (callProcess) -- From “process” library
say text = callProcess "espeak" ["--", text]
main = say "This is an example of speech synthesis."
JavaScript
This should work in most major browsers
var utterance = new SpeechSynthesisUtterance("This is an example of speech synthesis.");
window.speechSynthesis.speak(utterance);
Windows only:
var voice = new ActiveXObject("SAPI.SpVoice");
voice.speak("This is an example of speech synthesis.");
Julia
It seems that this and similar tasks can reduce to how the language can call an external program. Using the Julia REPL:
julia> a = "hello world"
"hello world"
julia> run(`espeak $a`)
Kotlin
Note that this code does not work on Windows 10.
Note also that Kotlin Native does not support the automatic translation of C function-like macros such as WIFEXITED and WEXITSTATUS.
Whilst it is often possible to wrap such macros in 'ordinary' C functions and then expose the latter to Kotlin via a .klib, it is not worth the effort here. I have therefore confined myself to simply reporting a non-zero error status.
// Kotlin Native v0.6.2
import kotlinx.cinterop.*
import platform.posix.*
fun talk(s: String) {
val pid = fork()
if (pid < 0) {
perror("fork")
exit(1)
}
if (pid == 0) {
execlp("espeak", "espeak", s, null)
perror("espeak")
_exit(1)
}
memScoped {
val status = alloc<IntVar>()
waitpid(pid, status.ptr, 0)
if (status.value > 0) println("Exit status was ${status.value}")
}
}
fun main(args: Array<String>) {
talk("This is an example of speech synthesis.")
}
Liberty BASIC
Assumes that 'espeak' is available at the path shown.
nomainwin
run "C:\Program Files\eSpeak\command_line\espeak "; chr$( 34); "This is an example of speech synthesis."; chr$( 34)
end
Another dll has been posted to do the same job, at LB Community Wiki
Locomotive Basic
Both hardware and software-only speech synthesizers exist for the CPC. A software-only solution, Speech 1.1 by Superior Software (1986), supplies three BASIC extension commands (RSXes), "|say", "|speak", and "|pitch":
|say,"This is an example of speech synthesis."
M2000 Interpreter
For Linux, through wine, if missing Sapi5 need this: winetricks speechsdk
Using Statement Speech
Module UsingStatementSpeech {
Volume 100
Speech "This is an example of speech synthesis."
}
UsingStatementSpeech
Print each word as speak
Module UsingEvents {
Declare WithEvents sp "SAPI.SpVoice"
That$="This is an example of speech synthesis."
EndStream=False
Function sp_Word {
Read New StreamNumber, StreamPosition, CharacterPosition, Length
Rem: Print StreamNumber, StreamPosition, CharacterPosition, Length
Print Mid$(That$, CharacterPosition+1, Length);" ";
Refresh
}
Function sp_EndStream {
Print
Refresh
EndStream=True
}
Const SVEStartInputStream = 2
Const SVEEndInputStream = 4
Const SVEVoiceChange = 8
Const SVEBookmark = 16
Const SVEWordBoundary = 32
Const SVEPhoneme = 64
Const SVESentenceBoundary = 128
Const SVEViseme = 256
Const SVEAudioLevel = 512
Const SVEPrivate = 32768
Const SVEAllEvents = 33790
Const SVSFDefault = 0&
Const SVSFlagsAsync = 1&
Const SVSFPurgeBeforeSpeak=2&
With sp, "EventInterests", SVEWordBoundary+SVEEndInputStream
Method sp, "Speak", That$, SVSFlagsAsync
While Not EndStream {Wait 10}
}
UsingEvents
Mathematica/Wolfram Language
Speak["This is an example of speech synthesis."]
Nim
Using same method as Julia.
import osproc
discard execCmd("espeak 'Hello world!'")
PARI/GP
Define a function that is using espeak package from Linux.
speak(txt,opt="")=extern(concat(["espeak ",opt," \"",txt,"\""]));
Now let it speak:
speak("This is an example of speech synthesis")
A monster speech tongue-twister:
speak("The seething sea ceaseth and thus the seething sea sufficeth us.","-p10 -s100")
A foreign language "Zungenbrecher":
speak("Fischers Fritz fischt frische Fische.","-vmb/mb-de2 -s130")
Perl
use Speech::Synthesis;
($engine) = Speech::Synthesis->InstalledEngines();
($voice) = Speech::Synthesis->InstalledVoices(engine => $engine);
Speech::Synthesis
->new(engine => $engine, voice => $voice->{id})
->speak("This is an example of speech synthesis.");
Phix
You can run this online here.
-- -- demo\rosetta\Speak.exw -- ====================== -- with javascript_semantics requires(6) -- WINDOWS or JS, not LINUX requires(32) -- Windows 32 bit only, for now... -- (^ runs fine on a 64-bit OS, but needs a 32-bit p.exe) requires("1.0.2") include builtins\speak.e -- (new in 1.0.2) constant text = "This is an example of speech synthesis" include pGUI.e function button_cb(Ihandle /*ih*/) speak(text) return IUP_CONTINUE end function IupOpen() Ihandle btn = IupButton("Speak",Icallback("button_cb")), dlg = IupDialog(IupHbox({btn},"MARGIN=180x80")) IupSetAttribute(dlg,"TITLE",text) IupShow(dlg) if platform()!=JS then IupMainLoop() IupClose() end if
Note that speech synthesis has refused to operate in a browser without user activation since 2018, hence the tiny GUI with a button.
Should you for some strange reason want it on desktop/Phix without any GUI, you'd need to arrange for COM initialisation etc yourself.
PHP
Linux & Mac example uses eSpeak (eSpeak Instillation instructions included in comments). Mac also has a built in Speech synthesis system and this example allows you to optionally use that instead of eSpeak. Windows example uses built in Windows Speech API.
<?php
<?php
/*
_ _____ _ _ _ ___ __
| | |_ _| \ | | | | \ \ / /
| | | | | \| | | | |\ V /
| | | | | . ` | | | | > <
| |____ _| |_| |\ | |__| |/ . \
|______|_____|_| \_|\____//_/ \_\
*/
// Install eSpeak - Run this command in a terminal
/*
sudo apt-get install eSpeak
*/
/*
__ __ _____
| \/ | /\ / ____|
| \ / | / \ | |
| |\/| | / /\ \| |
| | | |/ ____ \ |____
|_| |_/_/ \_\_____|
*/
// Mac has it's own Speech Synthesis system
// accessible via the "say" command.
// To use eSpeak on a Mac, change this variable to true.
$mac_use_espeak = false;
// To use eSpeak on a Mac you need to install
// Homebrew Package Manager & eSpeak
// Run these commands in a terminal:
/*
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install espeak
*/
$voice = "espeak";
$statement = 'Hello World!';
$save_file_args = '-w HelloWorld.wav'; // eSpeak args
// Ask PHP what OS it was compiled for,
// CAPITALIZE it and truncate to the first 3 chars.
$OS = strtoupper(substr(PHP_OS, 0, 3));
// If this is Darwin (MacOS) AND we don't want eSpeak
elseif($OS === 'DAR' && $mac_use_espeak == false) {
$voice = "say -v 'Victoria'";
$save_file_args = '-o HelloWorld.wav'; // say args
}
// Say It
exec("$voice '$statement'");
// Save it to a File
exec("$voice '$statement' $save_file_args");
<?php
// List available SAPI voices
// 0 = Microsoft David Desktop - English (United States)
// 1 = Microsoft Zira Desktop - English (United States)
// ... If you have additional voices installed
function ListSAPIVoices(&$voice){
foreach($voice->GetVoices as $v){
echo $v->GetDescription . PHP_EOL;
}
}
$filename = "DaisyBell.wav";
// https://en.wikipedia.org/wiki/Daisy_Bell#Computing_and_technology
// "In 1961, an IBM 704 at Bell Labs was programmed to sing "Daisy Bell"-
// in the earliest demonstration of computer speech synthesis."
$statement = "There is a flower within my heart, Daisy, Daisy!
Planted one day by a glancing dart,
Planted by Daisy Bell!
Whether she loves me or loves me not,
Sometimes it's hard to tell;
Yet I am longing to share the lot
Of beautiful Daisy Bell!
Daisy, Daisy,
Give me your answer, do!
I'm half crazy,
All for the love of you!
It won't be a stylish marriage,
I can't afford a carriage,
But you'll look sweet on the seat
Of a bicycle built for two!
We will go tandem as man and wife, Daisy, Daisy!
Ped'ling away down the road of life, I and my Daisy Bell!
When the road's dark we can both despise Po'leaseman and lamps as well;
There are bright lights in the dazzling eyes Of beautiful Daisy Bell!
Daisy, Daisy,
Give me your answer, do!
I'm half crazy,
All for the love of you!
It won't be a stylish marriage,
I can't afford a carriage,
But you'll look sweet on the seat
Of a bicycle built for two!
I will stand by you in wheel or woe, Daisy, Daisy!
You'll be the bell which I'll ring you know! Sweet little Daisy Bell!
You'll take the lead in each trip we take, Then if I don't do well;
I will permit you to use the brake, My beautiful Daisy Bell!";
// COM (Component Object Model) objects
// https://www.php.net/manual/en/book.com.php
$voice = new COM("SAPI.SpVoice");
$voice_file_stream = new COM("SAPI.SpVoice");
$file_stream = new COM("SAPI.SpFileStream");
// Change $voice to Zira
$voice->Voice = $voice->GetVoices()->Item(1);
// Change $voice_file_stream to David
$voice_file_stream->Voice = $voice_file_stream->GetVoices()->Item(0);
// Have voices announce themselves
//$voice->Speak($voice->Voice->GetDescription); // (Zira)
//$voice_file_stream->Speak($voice_file_stream->Voice->GetDescription); // (David)
/*
Select Stream Quality:
11kHz 8Bit Mono = 8
11kHz 8Bit Stereo = 9
11kHz 16Bit Mono = 10
11kHz 16Bit Stereo = 11
...
16kHz 8Bit Mono = 16
16kHz 8Bit Stereo = 17
16kHz 16Bit Mono = 18;
16kHz 16Bit Stereo = 19
...
32kHz 8Bit Mono = 28
32kHz 8Bit Stereo = 29
32kHz 16Bit Mono = 30
32kHz 16Bit Stereo = 31
...
*/
// Set stream quality
$file_stream->Format->Type = 17; // 16kHz 8Bit Stereo
/*
Select Speech StreamFile Mode:
Read = 0
ReadWrite = 1
Create = 2
CreateForWrite = 3
*/
$mode = 3;
// Have $voice (Zira) announce beginning file stream
$voice->Speak('Opening audio file stream');
// Output TTS to File
$file_stream->Open($filename, $mode); // Open stream and create file
$voice_file_stream->AudioOutputStream = $file_stream; // Begin streaming TTS
// Have $voice_file_stream (David) speak $statement
$voice_file_stream->Speak($statement);
$file_stream->Close; // Close stream
// Have $voice (Zira) announce file stream completion
$voice->Speak('File stream complete');
PicoLisp
(call 'espeak "This is an example of speech synthesis.")
PowerShell
Add-Type -AssemblyName System.Speech
$anna = New-Object System.Speech.Synthesis.SpeechSynthesizer
$anna.Speak("I'm sorry Dave, I'm afraid I can't do that.")
$anna.Dispose()
Python
import pyttsx
engine = pyttsx.init()
engine.say("It was all a dream.")
engine.runAndWait()
Quackery
Mac specific.
[ $ /
import subprocess
subprocess.run(["say",
string_from_stack()])
/ python ] is speak ( $ --> )
$ "This is an example of speech synthesis" speak
Racket
Should work on all platforms.
#lang racket
(require racket/lazy-require)
(lazy-require [ffi/com (com-create-instance com-release com-invoke)])
(define (speak text)
(cond [(eq? 'windows (system-type))
(define c (com-create-instance "SAPI.SpVoice"))
(com-invoke c "Speak" text)
(com-release c)]
[(ormap find-executable-path '("say" "espeak"))
=> (λ(exe) (void (system* exe text)))]
[else (error 'speak "I'm speechless!")]))
(speak "This is an example of speech synthesis.")
Raku
(formerly Perl 6)
run 'espeak', 'This is an example of speech synthesis.';
REXX
Programming note: This REXX program uses a freeware program NIRCMD to interface with the Microsoft Windows speech synthesizer program SAM, a text to speech using a male voice. SAM can possibly be configured to use other voices with later releases of Windows. More recent Microsoft Windows have another speech synthesizer program: ANNA.
/*REXX program uses a command line interface to invoke Windows SAM for speech synthesis.*/
parse arg t /*get the (optional) text from the C.L.*/
if t='' then exit /*Nothing to say? Then exit program.*/
dquote= '"'
rate= 1 /*talk: -10 (slow) to 10 (fast). */
/* [↓] where the rubber meets the road*/
'NIRCMD' "speak text" dquote t dquote rate /*NIRCMD invokes Microsoft's Sam voice*/
/*stick a fork in it, we're all done. */
Note: The name of the above REXX program is speak.rex
usage using the command:
speak This is an example of speech synthesis.
Ring
load "guilib.ring"
myApp = New qApp
{
Text = "Hello. This is an example of speech synthesis"
voice = new QTextToSpeech(null)
voice.Say(Text)
exec()
}
- Output:
"Hello. This is an example of speech synthesis"
Ring
load "guilib.ring"
load "stdlib.ring"
MyApp = New qApp {
win1 = new qWidget() {
setwindowtitle("Hello World")
setGeometry(100,100,370,250)
Text = "This is an example of speech synthesis"
Text = split(Text," ")
label1 = new qLabel(win1) {
settext("What is your name ?")
setGeometry(10,20,350,30)
setalignment(Qt_AlignHCenter)
}
btn1 = new qpushbutton(win1) {
setGeometry(10,200,100,30)
settext("Say Hello")
setclickevent("pHello()")
}
btn2 = new qpushbutton(win1) {
setGeometry(150,200,100,30)
settext("Close")
setclickevent("pClose()")
}
lineedit1 = new qlineedit(win1) {
setGeometry(10,100,350,30)
}
voice = new QTextToSpeech(win1) {
}
show()
}
exec()
}
Func pHello
lineedit1.settext( "Hello " + lineedit1.text())
for n = 1 to len(Text)
voice.Say(Text[n])
see Text[n] + nl
next
Func pClose
MyApp.quit()
- Output:
This is an example of speech synthesis
Ruby
Using this module to encapsulate operating system lookup
module OperatingSystem
require 'rbconfig'
module_function
def operating_system
case RbConfig::CONFIG["host_os"]
when /linux/i
:linux
when /cygwin|mswin|mingw|windows/i
:windows
when /darwin/i
:mac
when /solaris/i
:solaris
else
nil
end
end
def linux?; operating_system == :linux; end
def windows?; operating_system == :windows; end
def mac?; operating_system == :mac; end
end
Uses espeak
on Linux, say
on Mac, and the win32 SAPI library on Windows.
load 'operating_system.rb'
def speak(text)
if OperatingSystem.windows?
require 'win32/sapi5'
v = Win32::SpVoice.new
v.Speak(text)
elsif OperatingSystem.mac?
IO.popen(["say"], "w") {|pipe| pipe.puts text}
else
# Try to run "espeak". No OperatingSystem check: "espeak" is
# for Linux but is also an optional package for BSD.
IO.popen(["espeak", "-stdin"], "w") {|pipe| pipe.puts text}
end
end
speak 'This is an example of speech synthesis.'
Scala
import javax.speech.Central
import javax.speech.synthesis.{Synthesizer, SynthesizerModeDesc}
object ScalaSpeaker extends App {
def speech(text: String) = {
if (!text.trim.isEmpty) {
val VOICENAME = "kevin16"
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory")
Central.registerEngineCentral("com.sun.speech.freetts.jsapi.FreeTTSEngineCentral")
val synth = Central.createSynthesizer(null)
synth.allocate()
val desc = synth.getEngineModeDesc match {case g2: SynthesizerModeDesc => g2}
synth.getSynthesizerProperties.setVoice(desc.getVoices.find(_.toString == VOICENAME).get)
synth.speakPlainText(text, null)
synth.waitEngineState(Synthesizer.QUEUE_EMPTY)
synth.deallocate()
}
}
speech( """Thinking of Holland
|I see broad rivers
|slowly chuntering
|through endless lowlands,
|rows of implausibly
|airy poplars
|standing like tall plumes
|against the horizon;
|and sunk in the unbounded
|vastness of space
|homesteads and boweries
|dotted across the land,
|copses, villages,
|couchant towers,
|churches and elm-trees,
|bound in one great unity.
|There the sky hangs low,
|and steadily the sun
|is smothered in a greyly
|iridescent smirr,
|and in every province
|the voice of water
|with its lapping disasters
|is feared and hearkened.""".stripMargin)
}
Sidef
func text2speech(text, lang='en') {
Sys.run("espeak -v #{lang} -w /dev/stdout #{text.escape} | aplay");
}
text2speech("This is an example of speech synthesis.");
Swift
OS X comes with a program called "say," that does speech.
import Foundation
let task = NSTask()
task.launchPath = "/usr/bin/say"
task.arguments = ["This is an example of speech synthesis."]
task.launch()
Tcl
This just passes the string into the Festival system:
exec festival --tts << "This is an example of speech synthesis."
Alternatively, on MacOS X, you'd use the system say
program:
exec say << "This is an example of speech synthesis."
On Windows, there is a service available by COM for speech synthesis:
package require tcom
set msg "This is an example of speech synthesis."
set voice [::tcom::ref createobject Sapi.SpVoice]
$voice Speak $msg 0
Putting these together into a helper procedure, we get:
proc speak {msg} {
global tcl_platform
if {$tcl_platform(platform) eq "windows"} {
package require tcom
set voice [::tcom::ref createobject Sapi.SpVoice]
$voice Speak $msg 0
} elseif {$tcl_platform(os) eq "Darwin"} {
exec say << $msg
} else {
exec festival --tts << $msg
}
}
speak "This is an example of speech synthesis."
UNIX Shell
Here we use the open source espeak tool:
#!/bin/sh
espeak "This is an example of speech synthesis."
VBScript
Dim message, sapi
message = "This is an example of speech synthesis."
Set sapi = CreateObject("sapi.spvoice")
sapi.Speak message
Wren
The ability to call external processes such as espeak is expected to be added to Wren-cli in the next release. In the meantime, we embed the following Wren script in a minimal C host (no error checking) to complete this task.
/* Speech_synthesis.wren */
class C {
foreign static getInput(maxSize)
foreign static espeak(s)
}
System.write("Enter something to say (up to 100 characters) : ")
var s = C.getInput(100)
C.espeak(s)
We now embed this in the following C program, compile and run it.
/* gcc Speech_synthesis.c -o Speech_synthesis -lwren -lm */
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include "wren.h"
void C_getInput(WrenVM* vm) {
int maxSize = (int)wrenGetSlotDouble(vm, 1) + 2;
char input[maxSize];
fgets(input, maxSize, stdin);
__fpurge(stdin);
input[strcspn(input, "\n")] = 0;
wrenSetSlotString(vm, 0, (const char*)input);
}
void C_espeak(WrenVM* vm) {
const char *arg = wrenGetSlotString(vm, 1);
char command[strlen(arg) + 10];
strcpy(command, "espeak \"");
strcat(command, arg);
strcat(command, "\"");
system(command);
}
WrenForeignMethodFn bindForeignMethod(
WrenVM* vm,
const char* module,
const char* className,
bool isStatic,
const char* signature) {
if (strcmp(module, "main") == 0) {
if (strcmp(className, "C") == 0) {
if (isStatic && strcmp(signature, "getInput(_)") == 0) return C_getInput;
if (isStatic && strcmp(signature, "espeak(_)") == 0) return C_espeak;
}
}
return NULL;
}
static void writeFn(WrenVM* vm, const char* text) {
printf("%s", text);
}
char *readFile(const char *fileName) {
FILE *f = fopen(fileName, "r");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
rewind(f);
char *script = malloc(fsize + 1);
fread(script, 1, fsize, f);
fclose(f);
script[fsize] = 0;
return script;
}
int main(int argc, char **argv) {
WrenConfiguration config;
wrenInitConfiguration(&config);
config.writeFn = &writeFn;
config.bindForeignMethodFn = &bindForeignMethod;
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "Speech_synthesis.wren";
char *script = readFile(fileName);
wrenInterpret(vm, module, script);
wrenFreeVM(vm);
free(script);
return 0;
}
Zoomscript
For typing:
speak "This is an example of speech synthesis."
For importing:
¶0¶speak "This is an example of speech synthesis."
ZX Spectrum Basic
This example makes use of the Currah Speech Synthesizer peripheral device.
10 LET s$="(th)is is an exampul of sp(ee)(ch) sin(th)esis":PAUSE 1
- Programming Tasks
- Temporal media
- Speech synthesis
- 11l
- AmigaBASIC
- AppleScript
- AutoHotkey
- AutoIt
- BASIC256
- Batch File
- BBC BASIC
- C
- POSIX
- C sharp
- Clojure
- Facts/speech-synthesis
- FreeBASIC
- FutureBasic
- GlovePIE
- Go
- Groovy
- Haskell
- JavaScript
- Julia
- Kotlin
- Liberty BASIC
- Locomotive Basic
- M2000 Interpreter
- Mathematica
- Wolfram Language
- Nim
- PARI/GP
- Perl
- Phix
- Phix/pGUI
- Phix/online
- PHP
- PicoLisp
- PowerShell
- Python
- Quackery
- Racket
- Raku
- REXX
- Ring
- Ruby
- Win32-utils
- Scala
- FreeTTS
- Sidef
- Swift
- Tcl
- Tcom
- UNIX Shell
- VBScript
- Wren
- Zoomscript
- ZX Spectrum Basic
- TI-83 BASIC/Omit
- Maxima/Omit
- ML/I/Omit
- Zkl/Omit