Skip to content

gcp-tts 1.0.3

Install from the command line:
Learn more about npm packages
$ npm install @lesjoursfr/gcp-tts@1.0.3
Install via package.json:
"@lesjoursfr/gcp-tts": "1.0.3"

About this version

npm version QC Checks

gcp-tts

Generate audio files from text file using GCP.

Presentation

This module convert text to sound using the Google Cloud Text-to-Speech service.

import { Languages, synthesizeTextWithGCP, Voices } from "@lesjoursfr/gcp-tts";

let result = await synthesizeTextWithGCP(
	"Alice, assise auprès de sa sœur sur le gazon, …",
	{
		projectId: "gcp-project-id",
		clientOptions: { credentials: credentials },
		bucketId: "gcp-bucket-id",
	},
	{
		language: Languages.fr_FR,
		voice: Voices.fr_FR_Neural2_A,
		audioEncoding: "LINEAR16",
	},
	{ folder: "/an/absolute/path", filename: "filename-without-extension" }
);

You can also convert the generated file to WEBA and/or M4A. You need to have ffmpeg installed on your system to do that.

import {
	Codecs,
	Languages,
	synthesizeTextWithGCP,
	Voices,
} from "@lesjoursfr/gcp-tts";

let result = await synthesizeTextWithGCP(
	"Alice, assise auprès de sa sœur sur le gazon, …",
	{
		projectId: "gcp-project-id",
		clientOptions: { credentials: credentials },
		bucketId: "gcp-bucket-id",
	},
	{
		language: Languages.fr_FR,
		voice: Voices.fr_FR_Neural2_A,
		audioEncoding: "LINEAR16",
	},
	{ folder: "/an/absolute/path", filename: "filename-without-extension" },
	[{ codec: Codecs.weba }, { codec: Codecs.m4a }]
);

The return object is:

type SynthesizeResult = {
	sourceFile: string; // File path of the original generated file
	extraEncodes: Array<string>; // Array of file paths converted by ffmpeg
};

Details


Assets

  • gcp-tts-1.0.3.tgz

Download activity

  • Total downloads 10
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all