Skip to content

Commit

Permalink
refactor(text-to-speech): update extension details for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
cabljac committed May 8, 2023
1 parent fd2a9f6 commit 0f5564d
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 57 deletions.
18 changes: 0 additions & 18 deletions firestore-text-to-speech/PREINSTALL.md

This file was deleted.

16 changes: 0 additions & 16 deletions firestore-text-to-speech/functions/src/types.ts

This file was deleted.

3 changes: 3 additions & 0 deletions text-to-speech/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Version 0.1.0

Initial release of the _Convert Text to Speech_ extension.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## See it in action

This extension will automatically convert text from Firestore documents into speech and save the generated audio files in Cloud Storage for Firebase.

### See it in action
To use this extension, ensure that each document in the specified Firestore collection contains a text field with the content you want to convert to speech.
To use this extension, ensure that each document in the specified Firestore collection contains a text field with the content you want to convert to speech.

If you enabled per-document overrides during installation, you can also include fields such as languageCode, ssmlGender, audioEncoding, and voiceName in the document for customization.

### Example Usage
## Example Usage

```js
```javascript
admin
.firestore()
.collection("${param:COLLECTION_PATH}")
Expand All @@ -20,15 +21,16 @@ admin
});
```

### Access generated audio files
Once the extension is installed, it will automatically process new documents in the ${param:COLLECTION_PATH} collection and store the resulting audio files in your ${param:BUCKET} Cloud Storage bucket.
## Access generated audio files

Once the extension is installed, it will automatically process new documents in the ${param:COLLECTION_PATH} collection and store the resulting audio files in your ${param:BUCKET} Cloud Storage bucket.

The files will be named using the document ID with an appropriate file extension (e.g., .mp3 for MP3 files).

### Error handling:
## Error handling

If there are any errors during the text-to-speech conversion process, the extension will log the error message in the Cloud Functions logs. Make sure to monitor these logs and handle any errors appropriately in your application.

### Monitoring:
As a best practice, you can monitor the activity of your installed extension, including its health, usage, and logs, by visiting the Firebase Extensions dashboard in the Firebase Console.
## Monitoring

The Text-to-Speech Extension is now installed and ready to enhance your application by converting text in Firestore documents into speech.
As a best practice, you can [monitor the activity](https://firebase.google.com/docs/extensions/manage-installed-extensions#monitor) of your installed extension, including checks on its health, usage, and logs.
30 changes: 30 additions & 0 deletions text-to-speech/PREINSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
This extension converts text from Firestore documents into speech using the Google Cloud Text-to-Speech API.

Upon install you will be asked to provide a Firestore collection path and a Storage path. Any document writes to this collection will trigger a Cloud Function that does the following:

* Generates an audio version of the same text
* Stores it in Cloud Storage in the specified path
* Writes the path to the Storage object back in the same document.

## Use Cases
* Accessibility: A key strength of TTS lies in fostering inclusive access to digital content for people with visual impairments or who face reading challenges. By utilizing TTS, we can work towards providing equal opportunities for everyone to obtain information, acknowledging and embracing the diverse abilities and requirements of all users.
* Language learning: TTS can be a handy tool for language learners, as it can help users to practice their pronunciation and improve their listening comprehension. By providing accurate and natural-sounding speech, TTS can help language learners to develop their language skills in a more immersive and interactive way.
* Navigation: In-car navigation systems often use TTS to give drivers turn-by-turn directions. TTS can help drivers keep their eyes on the road and avoid distractions by providing spoken instructions, improving safety.
* Virtual assistants: Virtual assistants like Siri, Alexa, and Google Assistant rely heavily on TTS to provide users with helpful information and complete tasks. Using TTS, virtual assistants can create a more natural and conversational experience for users, enhancing their overall usability.

## Additional Setup

Before installing this extension, make sure that you've set up a [Cloud Firestore database](https://firebase.google.com/docs/firestore/quickstart) and [Cloud Storage bucket](https://firebase.google.com/docs/storage) in your Firebase project.

## Billing

To install an extension, your project must be on the Blaze (pay as you go) plan.

You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).

This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service's no-cost tier:

* [Google Cloud Text-to-Speech API](https://cloud.google.com/text-to-speech#section-11)
* Cloud Firestore
* Cloud Storage
* Cloud Functions (Node.js 14+ runtime. See [FAQs](https://firebase.google.com/support/faq#extensions-pricing))
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Text to Speech with Firestore and Storage
# Convert Text to Speech

**Author**: Firebase (**[https://firebase.google.com](https://firebase.google.com)**)
**Author**: Google Cloud (**[https://cloud.google.com/](https://cloud.google.com/)**)

**Description**: Converts text from Firestore documents into spoken audio files using Google Cloud Text-to-Speech API.
**Description**: Converts Firestore documents to audio files stored in Cloud Storage using Cloud Text to Speech.



Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,22 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: firestore-text-to-speech
version: 0.1.11
name: text-to-speech
version: 0.1.0
specVersion: v1beta

displayName: Text to Speech with Firestore and Storage
displayName: Convert Text to Speech
description:
Converts text from Firestore documents into spoken audio files using Google Cloud Text-to-Speech API.
Converts Firestore documents to audio files stored in Cloud Storage using Cloud Text to Speech.

license: Apache-2.0

sourceUrl: https://github.com/firebase/extensions/tree/master/firestore-translate-text
releaseNotesUrl: https://github.com/firebase/extensions/blob/master/firestore-translate-text/CHANGELOG.md
sourceUrl: https://github.com/GoogleCloudPlatform/firebase-extensions/tree/main/text-to-speech
releaseNotesUrl: https://github.com/GoogleCloudPlatform/firebase-extensions/blob/main/text-to-speech/CHANGELOG.md

author:
authorName: Firebase
url: https://firebase.google.com
authorName: Google Cloud
url: https://cloud.google.com/

contributors:
- authorName: Invertase
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 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
*
* https://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.
*/

import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
import config from './config';
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions text-to-speech/functions/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2023 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
*
* https://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.
*/

import * as tts from '@google-cloud/text-to-speech';

export type ISynthesizeSpeechRequest =
tts.protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest;
export type ISynthesizeSpeechResponse =
tts.protos.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse;
export type AudioEncoding =
| tts.protos.google.cloud.texttospeech.v1.AudioEncoding
| 'AUDIO_ENCODING_UNSPECIFIED'
| 'LINEAR16'
| 'MP3'
| 'OGG_OPUS'
| 'MULAW'
| 'ALAW';
export type SsmlVoiceGender =
tts.protos.google.cloud.texttospeech.v1.SsmlVoiceGender;
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 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
*
* https://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.
*/
import {
AudioEncoding,
ISynthesizeSpeechRequest,
Expand Down
File renamed without changes.

0 comments on commit 0f5564d

Please sign in to comment.