Skip to content

GCP.Speech reference

Source: src/GCP/Speech/CustomClass.ts

A Speech-to-Text Adaptation custom class. Custom classes group words that represent one concept (for example passenger ship names) and are referenced from PhraseSet hints as ${custom_class_id}.

Speech-to-Text v1 classes have no labels field and Alchemy does not write ownership into the items (they steer recognition). A generated id identifies the class; one with an explicit id that Alchemy has no state for is reported as unowned. Location and custom class id are identity — changing either replaces the class. items update in place.

Generated id

const ships = yield* GCP.Speech.CustomClass("Ships", {
items: [{ value: "sloop" }, { value: "ketch" }],
});

Explicit id and location

const ships = yield* GCP.Speech.CustomClass("Ships", {
location: "global",
customClassId: "passenger-ships",
items: [{ value: "sloop" }],
});
const ships = yield* GCP.Speech.CustomClass("Ships", {
items: [{ value: "brig" }, { value: "barque" }],
});

Source: src/GCP/Speech/GetCustomClass.ts

Runtime binding for Speech-to-Text customClasses.get.

Bind this operation to a CustomClass in a Function/Action init phase. Provide GetCustomClassHttp.

Grants roles/speech.client on the project because Speech-to-Text has no resource-level IAM.

const getClass = yield* GCP.Speech.GetCustomClass(ships);
const live = yield* getClass();

Source: src/GCP/Speech/GetCustomClassHttp.ts Kind: Layer · Provides: GCP.Speech.GetCustomClass

HTTP implementation of GetCustomClass.

Source: src/GCP/Speech/GetPhraseSet.ts

Runtime binding for Speech-to-Text phraseSets.get.

Bind this operation to a PhraseSet in a Function/Action init phase. Provide GetPhraseSetHttp.

Grants roles/speech.client on the project because Speech-to-Text has no resource-level IAM.

const getPhraseSet = yield* GCP.Speech.GetPhraseSet(hints);
const live = yield* getPhraseSet();

Source: src/GCP/Speech/GetPhraseSetHttp.ts Kind: Layer · Provides: GCP.Speech.GetPhraseSet

HTTP implementation of GetPhraseSet.

Source: src/GCP/Speech/PhraseSet.ts

A Speech-to-Text Adaptation phrase set. Phrase sets bias recognition toward listed words and phrases, including references to custom classes (${custom_class_id}).

Speech-to-Text v1 phrase sets have no labels field and Alchemy does not write ownership into the phrases (they bias recognition). A generated id identifies the set; one with an explicit id that Alchemy has no state for is reported as unowned. Location and phrase set id are identity — changing either replaces the set. phrases and boost update in place.

Generated id

const hints = yield* GCP.Speech.PhraseSet("Hints", {
phrases: [{ value: "weather", boost: 10 }],
boost: 5,
});

Explicit id with a custom class reference

const hints = yield* GCP.Speech.PhraseSet("Hints", {
phraseSetId: "weather-hints",
phrases: [{ value: "sail on ${passenger-ships}" }],
});
const hints = yield* GCP.Speech.PhraseSet("Hints", {
phrases: [
{ value: "weather", boost: 15 },
{ value: "forecast" },
],
boost: 8,
});

Source: src/GCP/Speech/Recognize.ts

Runtime binding for Speech-to-Text speech.recognize using a PhraseSet as Adaptation.

Bind this operation to a PhraseSet in a Function/Action init phase. Provide RecognizeHttp.

Grants roles/speech.client on the project because Speech-to-Text has no resource-level IAM.

const recognize = yield* GCP.Speech.Recognize(hints);
const result = yield* recognize({
body: {
config: { languageCode: "en-US" },
audio: { uri: "gs://bucket/clip.flac" },
},
});

Source: src/GCP/Speech/RecognizeHttp.ts Kind: Layer · Provides: GCP.Speech.Recognize

HTTP implementation of Recognize.