This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let synth = AVSpeechSynthesizer() | |
let utterance = AVSpeechUtterance(string: "Some text") | |
let voice = AVSpeechSynthesisVoice(language: "en-US") | |
synth.speak(utterance) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVFoundation | |
enum VoiceType: String { | |
case undefined | |
case waveNetFemale = "en-US-Wavenet-F" | |
case waveNetMale = "en-US-Wavenet-D" | |
case standardFemale = "en-US-Standard-E" | |
case standardMale = "en-US-Standard-D" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="SpeechRecognizer" extends="Task" > | |
<script type="text/brightscript" uri="pkg:/components/SpeechRecognizer.brs"/> | |
<interface> | |
<!-- Callback listener --> | |
<field id="delegate" type="node"/> | |
<function name="startListening"/> | |
</interface> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startListening(params = invalid) | |
m.top.functionName = "runRecognizer" | |
m.top.control = "RUN" | |
end function | |
sub runRecognizer() | |
mic = createObject("roMicrophone") | |
' If can't record, there's no point on continuing | |
if not mic.CanRecord() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.recognizer = CreateObject("roSGNode", "SpeechRecognizer") | |
m.recognizer.delegate = m.top | |
m.recognizer.callFunc("startListening", {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recognizer() | |
if m.recognizer = invalid | |
m.recognizer = CreateObject("roSGNode", "SpeechRecognizer") | |
m.recognizer.delegate = m.top | |
end if | |
return m.recognizer | |
end function | |
function onKeyEvent(key as String, press as Boolean) as Boolean | |
if key = "OK" and press |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="AppScene" extends="Scene"> | |
<interface> | |
<!-- Speech Recognizer callbacks --> | |
<function name="speechRecognizerDidReceiveTranscript"/> | |
</interface> | |
<script type="text/brightscript" uri="pkg:/components/AppScene.brs"/> | |
</component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function speechRecognizerDidReceiveTranscript(transcript as String) | |
m.label.text = transcript | |
m.infoLb.text = "Hold the OK button to start dictation, release it once you're done." | |
end function |
OlderNewer