1. Answers
  2. Customizing Google Cloud Text-to-Speech in TypeScript

How do I customize Google Cloud Text-to-Speech in TypeScript?

In this guide, we will learn how to customize Google Cloud Text-to-Speech using Pulumi in TypeScript. We will create a custom class and a phrase set to tailor the speech synthesis to our needs. These custom resources allow us to define specific phrases and words that the Text-to-Speech API should recognize and pronounce correctly.

Key Points:

  • We will create a custom class for specific words or phrases.
  • We will create a phrase set to boost the recognition of certain phrases.
  • We will use Pulumi to manage these resources in Google Cloud.

Concluding Summary:

By the end of this guide, you will have a Pulumi program in TypeScript that customizes Google Cloud Text-to-Speech using a custom class and a phrase set.

import * as pulumi from "@pulumi/pulumi";
import * as googleNative from "@pulumi/google-native";

// Create a custom class for specific words or phrases
const customClass = new googleNative.speech.v1.CustomClass("myCustomClass", {
    name: "projects/my-project/locations/global/customClasses/myCustomClass",
    items: [
        { value: "Pulumi" },
        { value: "infrastructure as code" },
    ],
    project: "my-project",
    location: "global",
    customClassId: "myCustomClass",
});

// Create a phrase set to boost the recognition of certain phrases
const phraseSet = new googleNative.speech.v1.PhraseSet("myPhraseSet", {
    name: "projects/my-project/locations/global/phraseSets/myPhraseSet",
    boost: 10,
    phrases: [
        { value: "Pulumi" },
        { value: "infrastructure as code" },
    ],
    project: "my-project",
    location: "global",
    phraseSetId: "myPhraseSet",
});

// Export the names of the created resources
export const customClassName = customClass.name;
export const phraseSetName = phraseSet.name;

Key Points:

  • We created a custom class using googleNative.speech.v1.CustomClass.
  • We defined specific words or phrases in the custom class.
  • We created a phrase set using googleNative.speech.v1.PhraseSet.
  • We boosted the recognition of certain phrases using the phrase set.
  • We exported the names of the created resources for reference.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up