Difference between revisions of "System.Speak"

From Xojo Documentation

(Added missing parameter)
(Notes)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
| name=Speak
 
| name=Speak
 
| scope=public
 
| scope=public
| owner=System
+
| owner=[[System]]
 
| ownertype=module
 
| ownertype=module
 
| parameters=value As [[String]]
 
| parameters=value As [[String]]
Line 31: Line 31:
  
 
On Linux, Speak uses the [http://espeak.sourceforge.net/ eSpeak] library which is installed by default on Ubuntu 10.04 and newer.
 
On Linux, Speak uses the [http://espeak.sourceforge.net/ eSpeak] library which is installed by default on Ubuntu 10.04 and newer.
 +
 +
{{Information|Speak is only supported for Desktop and Mobile projects.}}
  
 
== Sample Code ==
 
== Sample Code ==
The following code in a [[PushButton]] pronounces the phrase entered into a [[TextField]].
+
The following code in a [[DesktopButton]] pronounces the phrase entered into a [[DesktopTextField]].
 
<rbcode>
 
<rbcode>
If TextField1.Value <> "" Then
+
If TextField1.Text <> "" Then
   System.Speak(TextField1.Value)
+
   System.Speak(TextField1.Text)
 
Else
 
Else
 
   System.Speak("Please enter some text in the field!")
 
   System.Speak("Please enter some text in the field!")

Latest revision as of 15:58, 23 February 2022

Method

System.Speak(value As String)

New in 2019r2

Supported for all project types and targets.

Uses the built-in speech synthesizer to pronounce the passed text string.

Usage

Speak(phrase [,Interrupt])

Part Type Description
phrase String or Variant Text string to be passed to the speech synthesizer. Speak will accept any variant that can be expressed as a string.
Interrupt Boolean Optional interrupt flag. If set to True, the call will terminate the previous calls to Speak. If omitted, False is assumed.

Notes

Speak takes a string (or any variant that can be expressed as a string) and uses the Windows or Macintosh text-to-speech engine to speak the text. The speech is asynchronous, allowing normal program flow to continue. By default, subsequent calls to Speak before the first call has finished will queue up and speak after the completion of the previous call. If the optional interrupt flag is used and set to True, the previous Speak calls will be stopped immediately.

On Linux, Speak uses the eSpeak library which is installed by default on Ubuntu 10.04 and newer.

fa-info-circle-32.png
Speak is only supported for Desktop and Mobile projects.

Sample Code

The following code in a DesktopButton pronounces the phrase entered into a DesktopTextField.

If TextField1.Text <> "" Then
System.Speak(TextField1.Text)
Else
System.Speak("Please enter some text in the field!")
End If

See Also

IDE Scripting Speak command