Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate code from googleapis/nodejs-text-to-speech #2872

Merged
merged 122 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
56156f5
Sample: List available voices [tts_list_voices]
Mar 22, 2018
c2a068f
Samples: Synthesize Speech (text, ssml, string, local file)
Mar 23, 2018
8ecf6cd
Samples: extract speech synthesis samples
Mar 23, 2018
e0e2dfb
s/var/const/g
Mar 23, 2018
b1f73c3
Samples: add quickstart
Mar 23, 2018
abfc908
Samples: change printed output after writing mp3 files
Mar 23, 2018
0827701
Samples: update with prettier
Mar 23, 2018
d9ba468
$ npm run generate-scaffolding
Mar 23, 2018
3029886
Samples: fix lint error for unused closure arg var
Mar 23, 2018
ff8f4c7
Samples: use simple SSML examples, eg. <speak>Hello there.</speak>
Mar 23, 2018
3cfccfe
Update links and whatnot
Mar 24, 2018
35b2ef9
making lint and samples work in circle
alexander-fenster Mar 24, 2018
a4944fb
samples package.json
alexander-fenster Mar 24, 2018
938bd29
Merge branch 'samples' of github.com:googleapis/nodejs-text-to-speech…
alexander-fenster Mar 24, 2018
ab5a54e
Update synthesize.js sample CLI help to show existing TXT and SSML re…
Mar 24, 2018
15c3577
Merge branch 'samples' of github.com:googleapis/nodejs-text-to-speech…
Mar 24, 2018
de41058
s/SSML Gender/SSML Voice Gender/g
Mar 24, 2018
2377562
Samples: update writing bytes to mp3 files to be async
Mar 24, 2018
ed79d9b
Update quickstart to write mp3 file asynchronously
Mar 24, 2018
43b197f
Samples: Use async I/O when writing MP3 files
Mar 24, 2018
caba487
Samples - updated with prettier
Mar 24, 2018
44cf9f4
Samples: update Quickstart to use async file I/O when writing MP3 file
Mar 24, 2018
9ffd714
make lint pass
alexander-fenster Apr 27, 2018
2143105
chore: lock files maintenance (#14)
alexander-fenster May 2, 2018
7317e04
chore: lock files maintenance (#16)
alexander-fenster May 8, 2018
509f788
chore: lock files maintenance (#21)
alexander-fenster May 22, 2018
3ccb1b2
codegen: check in synth.py; gapic-generate v1beta1 (#27)
jkwlui Jun 18, 2018
b7f9137
chore: bump version to 0.2.0 (#28)
jkwlui Jun 18, 2018
d11312b
chore: update sample lockfiles (#34)
JustinBeckwith Jun 25, 2018
a3a9758
refactor: drop repo-tool as an exec wrapper (#35)
JustinBeckwith Jun 26, 2018
9450d72
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2.…
renovate[bot] Jun 28, 2018
9458699
fix(deps): update dependency yargs to v11 (#43)
renovate[bot] Jun 28, 2018
427a599
chore(deps): update dependency ava to ^0.25.0 (#37)
renovate[bot] Jun 28, 2018
55ae08a
fix(deps): update dependency yargs to v12 (#44)
renovate[bot] Jun 28, 2018
298563a
chore(deps): update dependency eslint to v5 (#42)
renovate[bot] Jun 28, 2018
dd6a1bd
Fixed the wrong region tag (#46)
happyhuman Jul 2, 2018
f0a3b19
chore(deps): lock file maintenance (#47)
renovate[bot] Jul 3, 2018
cb8bce4
chore(deps): lock file maintenance (#50)
renovate[bot] Jul 10, 2018
0f3951c
chore(deps): lock file maintenance (#51)
renovate[bot] Jul 10, 2018
2bce306
chore(deps): lock file maintenance (#52)
renovate[bot] Jul 10, 2018
014c4e3
release: nodejs-text-to-speech v0.3.0 (#55)
jkwlui Jul 11, 2018
d950440
chore(deps): lock file maintenance (#56)
renovate[bot] Jul 17, 2018
35cbdc8
chore(deps): lock file maintenance (#59)
renovate[bot] Jul 24, 2018
b15d06e
chore: require node 8 for samples (#61)
JustinBeckwith Jul 30, 2018
64aa2a1
chore(deps): lock file maintenance (#62)
renovate[bot] Jul 31, 2018
4ff8e49
Code Samples demonstrating Audio Profiles (#31)
CallistoCF Aug 3, 2018
e787d12
chore: remove bonus whitespace
dpebot Aug 4, 2018
977761d
chore(deps): lock file maintenance (#67)
renovate[bot] Aug 7, 2018
b68edf0
chore: ignore package-lock.json (#69)
JustinBeckwith Aug 7, 2018
e2bc09d
Update region tags to standard (#75)
alixhami Aug 21, 2018
cc97e5d
chore(deps): update dependency canvas to v2 (#102)
renovate[bot] Oct 20, 2018
ae8f8a7
chore: remove unused deps and cleanup (#125)
JustinBeckwith Nov 9, 2018
1f2552d
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 …
renovate[bot] Nov 10, 2018
5cb93dd
docs(samples): updated samples code to use async await (#118)
praveenqlogic Nov 15, 2018
36ae426
refactor(samples): convert sample tests from ava to mocha (#133)
nareshqlogic Nov 23, 2018
10b8381
chore: removed async from dependency list (#140)
vijay-qlogic Nov 27, 2018
ca6e511
Release v0.4.0 (#151)
jkwlui Dec 6, 2018
a9010d8
refactor: modernize the sample tests (#164)
JustinBeckwith Dec 26, 2018
cee7b9c
Release v0.5.0 (#180)
jkwlui Feb 6, 2019
70d0142
fix(deps): update dependency yargs to v13 (#187)
renovate[bot] Feb 12, 2019
e15196e
docs: update sample to show method inside of async function (#188)
nirupa-kumar Feb 14, 2019
c0b373d
Release v0.5.1 (#192)
JustinBeckwith Feb 19, 2019
c5fed7a
chore(deps): update dependency mocha to v6
renovate[bot] Feb 19, 2019
944aa05
refactor: use execSync for tests (#207)
JustinBeckwith Apr 4, 2019
2a11d31
refactor: wrap execSync with encoding: utf-8 (#208)
jkwlui Apr 5, 2019
751daa8
chore: release 1.0.0 (#225)
bcoe May 14, 2019
6ac81b3
chore: release 1.1.0 (#235)
yoshi-automation Jun 5, 2019
4afc006
chore: release 1.1.1 (#240)
yoshi-automation Jun 14, 2019
9f3dd4f
chore: release 1.1.2 (#243)
yoshi-automation Jun 26, 2019
8a47f20
chore: release 1.1.3 (#251)
yoshi-automation Aug 2, 2019
98acea2
fix(deps): update dependency yargs to v14
renovate-bot Aug 20, 2019
3215741
chore: release 1.1.4 (#254)
yoshi-automation Aug 28, 2019
fb5ac72
chore: release 1.2.0 (#260)
yoshi-automation Sep 5, 2019
a2c6dd8
feat: code samples for ssml addresses tutorial (#257)
crowdus Sep 5, 2019
98c415e
chore: release 1.3.0 (#262)
yoshi-automation Sep 16, 2019
fd9ab20
chore: release 1.4.1 (#281)
release-please[bot] Oct 22, 2019
4b52005
chore: release 2.0.0 (#292)
release-please[bot] Nov 15, 2019
900a481
fix(deps): update dependency yargs to v15 (#295)
renovate-bot Nov 18, 2019
61cd3f5
chore: release 2.0.1 (#296)
release-please[bot] Nov 18, 2019
d2bcbb2
chore: release 2.0.2 (#300)
release-please[bot] Nov 21, 2019
4e133e9
chore: update license headers (#305)
JustinBeckwith Nov 25, 2019
a2bab5c
chore: release 2.1.0 (#310)
release-please[bot] Dec 11, 2019
63f14d9
refactor: use explicit mocha imports (#319)
JustinBeckwith Dec 30, 2019
7d45732
fix: move region tag to encompass catch (#320)
leahecole Dec 30, 2019
f084c97
chore: release 2.1.1 (#313)
release-please[bot] Dec 31, 2019
f14c2ec
chore: release 2.1.2
release-please[bot] Jan 6, 2020
a8e081c
chore(deps): update dependency mocha to v7 (#325)
renovate-bot Jan 6, 2020
641538b
chore: release 2.1.3 (#332)
release-please[bot] Feb 5, 2020
24c0434
chore: release 2.2.0 (#346)
release-please[bot] Feb 12, 2020
8cf4d84
chore: release 2.3.0 (#351)
release-please[bot] Mar 11, 2020
d149894
feat!: drop node8 support (#373)
alexander-fenster Mar 31, 2020
cac97bb
fix: remove unused files in package (#389)
JustinBeckwith Apr 13, 2020
8e09e5f
chore: release 3.0.0 (#374)
release-please[bot] Jun 4, 2020
016caee
chore(deps): update dependency mocha to v8 (#412)
renovate-bot Jun 11, 2020
3091cf9
chore: release 3.0.1 (#414)
release-please[bot] Jun 29, 2020
f9426a3
chore(deps): no canvas (#417)
alexander-fenster Jul 2, 2020
d440f29
chore: release 3.1.0 (#433)
release-please[bot] Jul 30, 2020
536d46a
fix(deps): update dependency yargs to v16 (#446)
renovate-bot Sep 9, 2020
ac33ef4
chore: release 3.1.1 (#447)
release-please[bot] Sep 17, 2020
b5d0352
docs(samples): updates effects profile sample (#442)
telpirion Sep 22, 2020
1c267bc
chore: release 3.1.2 (#464)
release-please[bot] Nov 16, 2020
929806f
chore: release 3.1.3 (#467)
release-please[bot] Dec 2, 2020
08c11e7
chore: release 3.2.0 (#491)
release-please[bot] Apr 16, 2021
91a2e52
chore: release 3.2.1 (#506)
release-please[bot] May 12, 2021
aebfd85
chore: release 3.2.2 (#517)
release-please[bot] Jun 6, 2021
b5e5c44
chore: release 3.2.3 (#526)
release-please[bot] Jun 23, 2021
01b729f
chore: release 3.2.4 (#531)
release-please[bot] Jun 30, 2021
2a72e3a
chore: release 3.2.5 (#533)
release-please[bot] Jul 12, 2021
3fd2b2c
chore: release 3.2.6 (#535)
release-please[bot] Jul 21, 2021
aa0774d
chore: release 3.2.7 (#542)
release-please[bot] Aug 17, 2021
2847e9a
chore: release 3.3.0 (#544)
release-please[bot] Aug 23, 2021
36ec94a
chore: release 3.3.1 (#549)
release-please[bot] Sep 10, 2021
2888638
chore: release 3.4.0 (#563)
release-please[bot] Dec 9, 2021
53c2d9b
build!: update library to use Node 12 (#604)
sofisl May 19, 2022
2041c08
chore(main): release 4.0.0 (#606)
release-please[bot] Jun 20, 2022
dee088e
chore(main): release 4.0.1 (#611)
release-please[bot] Jun 30, 2022
73da70d
chore(main): release 4.0.2 (#621)
release-please[bot] Aug 26, 2022
f3b45d1
chore(main): release 4.0.3 (#626)
release-please[bot] Sep 22, 2022
6653980
chore(main): release 4.0.4 (#643)
release-please[bot] Nov 10, 2022
bd9b00c
Merge remote-tracking branch 'migration/main' into nodejs-text-to-spe…
kweinmeister Nov 18, 2022
737ae5b
ci: updates to workflow and CODEOWNERS
kweinmeister Nov 18, 2022
e0e9bdb
Merge branch 'main' into nodejs-text-to-speech-migration
kweinmeister Nov 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/texttospeech.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: texttospeech
on:
push:
branches:
- main
paths:
- 'texttospeech/**'
pull_request:
paths:
- 'texttospeech/**'
pull_request_target:
types: [labeled]
paths:
- 'texttospeech/**'
schedule:
- cron: '0 0 * * 0'
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: 'write'
pull-requests: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v3.1.0
with:
ref: ${{github.event.pull_request.head.sha}}
- uses: 'google-github-actions/auth@v1.0.0'
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
create_credentials_file: 'true'
access_token_lifetime: 600s
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install
working-directory: texttospeech
- run: npm test
working-directory: texttospeech
env:
MOCHA_REPORTER_SUITENAME: texttospeech
MOCHA_REPORTER_OUTPUT: texttospeech_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule'}}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"scheduler",
"speech",
"talent",
"texttospeech",
"translate",
"video-intelligence",
"contact-center-insights",
Expand Down
7 changes: 7 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ monitoring/opencensus @GoogleCloudPlatform/nodejs-samples-reviewers

# Data & AI
contact-center-insights @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
datalabeling @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
document-ai @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
mediatranslation @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
speech @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
talent @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
texttospeech @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
translate @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
video-intelligence @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers

# DEE-PO
error-reporting @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers
3 changes: 3 additions & 0 deletions texttospeech/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-console: off
65 changes: 65 additions & 0 deletions texttospeech/audioProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';
async function main(
text = 'Hello Everybody! This is an audio profile optimized sound byte.',
outputFile = './resources/phone.mp3',
languageCode = 'en-US',
ssmlGender = 'FEMALE'
) {
//[START tts_synthesize_text_audio_profile]

/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const text = 'Text you want to vocalize';
// const outputFile = 'YOUR_OUTPUT_FILE_LOCAtION;
// const languageCode = 'LANGUAGE_CODE_FOR_OUTPUT';
// const ssmlGender = 'SSML_GENDER_OF_SPEAKER';

// Imports the Google Cloud client library
const speech = require('@google-cloud/text-to-speech');
const fs = require('fs');
const util = require('util');

// Creates a client
const client = new speech.TextToSpeechClient();

async function synthesizeWithEffectsProfile() {
// Add one or more effects profiles to array.
// Refer to documentation for more details:
// https://cloud.google.com/text-to-speech/docs/audio-profiles
const effectsProfileId = ['telephony-class-application'];

const request = {
input: {text: text},
voice: {languageCode: languageCode, ssmlGender: ssmlGender},
audioConfig: {audioEncoding: 'MP3', effectsProfileId: effectsProfileId},
};

const [response] = await client.synthesizeSpeech(request);
const writeFile = util.promisify(fs.writeFile);
await writeFile(outputFile, response.audioContent, 'binary');
console.log(`Audio content written to file: ${outputFile}`);
}
// [END tts_synthesize_text_audio_profile]

synthesizeWithEffectsProfile();
}

main(...process.argv.slice(2)).catch(err => {
console.error(err);
process.exitCode = 1;
});
Binary file added texttospeech/hello.mp3
Binary file not shown.
53 changes: 53 additions & 0 deletions texttospeech/listVoices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

async function listVoices() {
// [START tts_list_voices]
const textToSpeech = require('@google-cloud/text-to-speech');

const client = new textToSpeech.TextToSpeechClient();

const [result] = await client.listVoices({});
const voices = result.voices;

console.log('Voices:');
voices.forEach(voice => {
console.log(`Name: ${voice.name}`);
console.log(` SSML Voice Gender: ${voice.ssmlGender}`);
console.log(` Natural Sample Rate Hertz: ${voice.naturalSampleRateHertz}`);
console.log(' Supported languages:');
voice.languageCodes.forEach(languageCode => {
console.log(` ${languageCode}`);
});
});
// [END tts_list_voices]
}

async function main() {
require(`yargs`) // eslint-disable-line
.demand(1)
.command('list-voices', 'List supported voices.', {}, () => listVoices())
.example('node $0 list-voices')
.wrap(120)
.recommendCommands()
.epilogue(
'For more information, see https://cloud.google.com/text-to-speech/docs'
)
.help()
.strict().argv;
}

main().catch(console.error);
24 changes: 24 additions & 0 deletions texttospeech/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "nodejs-docs-samples-text-to-speech",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": "googleapis/nodejs-text-to-speech",
"files": [
"*.js"
],
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"test": "mocha --timeout=60000"
},
"dependencies": {
"@google-cloud/text-to-speech": "^4.0.4",
"yargs": "^16.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^8.0.0"
}
}
51 changes: 51 additions & 0 deletions texttospeech/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main() {
// [START tts_quickstart]
// Imports the Google Cloud client library
const textToSpeech = require('@google-cloud/text-to-speech');

// Import other required libraries
const fs = require('fs');
const util = require('util');
// Creates a client
const client = new textToSpeech.TextToSpeechClient();
async function quickStart() {
// The text to synthesize
const text = 'hello, world!';

// Construct the request
const request = {
input: {text: text},
// Select the language and SSML voice gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};

// Performs the text-to-speech request
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
const writeFile = util.promisify(fs.writeFile);
await writeFile('output.mp3', response.audioContent, 'binary');
console.log('Audio content written to file: output.mp3');
}
quickStart();
// [END tts_quickstart]
}

main(...process.argv.slice(2));
4 changes: 4 additions & 0 deletions texttospeech/resources/example.ssml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<speak>123 Street Ln, Small Town, IL 12345 USA
<break time="2s"/>1 Jenny St &amp; Number St, Tutone City, CA 86753
<break time="2s"/>1 Piazza del Fibonacci, 12358 Pisa, Italy
<break time="2s"/></speak>
3 changes: 3 additions & 0 deletions texttospeech/resources/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
123 Street Ln, Small Town, IL 12345 USA
1 Jenny St & Number St, Tutone City, CA 86753
1 Piazza del Fibonacci, 12358 Pisa, Italy
Binary file added texttospeech/resources/expected_example.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions texttospeech/resources/hello.ssml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<speak>Hello there.</speak>
1 change: 1 addition & 0 deletions texttospeech/resources/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello there.
Loading