MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

www/js/_hyperscript.js:8649–8667  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

8647 this.args = { text, voice, rate, pitch, volume };
8648 }
8649 static parse(parser) {
8650 if (!parser.matchToken("speak")) return;
8651 var text = parser.requireElement("expression");
8652 var voice = null, rate = null, pitch = null, volume = null;
8653 while (parser.matchToken("with")) {
8654 if (parser.matchToken("voice")) {
8655 voice = parser.requireElement("expression");
8656 } else if (parser.matchToken("rate")) {
8657 rate = parser.requireElement("expression");
8658 } else if (parser.matchToken("pitch")) {
8659 pitch = parser.requireElement("expression");
8660 } else if (parser.matchToken("volume")) {
8661 volume = parser.requireElement("expression");
8662 } else {
8663 parser.raiseExpected("voice", "rate", "pitch", "volume");
8664 }
8665 }
8666 return new _SpeakCommand(text, voice, rate, pitch, volume);
8667 }
8668 resolve(ctx, { text, voice, rate, pitch, volume }) {
8669 var utterance = new SpeechSynthesisUtterance(String(text));
8670 if (voice) {

Callers

nothing calls this directly

Calls 3

matchTokenMethod · 0.45
requireElementMethod · 0.45
raiseExpectedMethod · 0.45

Tested by

no test coverage detected