1.0.5 • Published 8 months ago

@lesjoursfr/gcp-tts v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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
};
1.0.5

8 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

12 months ago

1.0.0

12 months ago