Blockly.Blocks['sound_recognition'] = {init: function() {this.appendDummyInput().appendField("Speech Synthesis");this.appendDummyInput().appendField("Choose Language:").appendField(new Blockly.FieldDropdown([["US English Male","E"], ["Chinese Female","CF"], ["Chinese Male","CM"], ["Korean Female","K"]]), "lang_");this.appendStatementInput("recognition_");this.setPreviousStatement(true);this.setNextStatement(true);this.setColour(230);this.setTooltip("");this.setHelpUrl("");}};Blockly.JavaScript['sound_recognition'] = function(block) {dropdown_lang_ = block.getFieldValue('lang_');var statements_recognition_ = Blockly.JavaScript.statementToCode(block, 'recognition_');if(dropdown_lang_=="E"){responsiveVoice.setDefaultVoice("US English Male");var code=responsiveVoice.speak(statements_recognition_);}return code;};
3 回答
至尊宝的传说
TA贡献1789条经验 获得超10个赞
statements_recognition_这个变量如果是字符串的话,作为参数时需要用引号的。字符串拼接用双引号,内部参数用双引号;或者相反。这是个小的js编写技巧。可以自己体会一下。
添加回答
举报
0/150
提交
取消