Artyom.js 中文翻译
  • Artyom
  • FAQ
  • 翻译相关
  • 开始
    • 简介
    • 必要条件
    • Changelog
  • API
    • isObeying
    • addCommands
    • clearGarbageCollection
    • debug
    • detectErrors
    • device
    • emptyCommands
    • fatality
    • getAvailableCommands
    • getLanguage
    • getProperties
    • getVoices
    • initialize
    • isRecognizing
    • isSpeaking
    • newDictation
    • newPrompt
    • obey
    • on
    • recognizingSupported
    • redirectRecognizedTextOutput
    • remoteProcessorService
    • removeCommands
    • repeatLastSay
    • restart
    • say
    • sayRandom
    • setDebug
    • Shutup
    • simulateInstruction
    • speechSupported
    • when
Powered by GitBook
On this page

Was this helpful?

  1. API

simulateInstruction

通过字符串的方式模拟语音命令的执行。

simulateInstruction 函数用于模拟命令的执行。该函数设计的初衷是为了测试功能(比如无麦克风测试)。函数接受的第一参数为字符串类型,函数会将其识别为“说出的文本”,而artyom会将该文本与命令进行匹配。

Parameters

type

instruction

String

Returns

type

if the instruction exists or matches with an existing command, will return true otherwise false. Includes messages in the console

boolean

如果模拟指令与任何已知的命令达成匹配,则会返回true,否则则会返回false,本方法允许用户仅适用文本模拟声音命令。

例子

let artyom = new Artyom();

/**
 * Add a command that reacts to "Hello"
 */
artyom.addCommands([
    {
        indexes:["Hello"],
        action:function(){
            alert("Hey, how are you");
        }
    }
]);


artyom.simulateInstruction("Hello"); //Simulate a voice  command with voice "hello".
PreviousShutupNextspeechSupported

Last updated 5 years ago

Was this helpful?