Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Add documentation for Text To Speech pipeline

davidmezzetti277068b4c23f
diff --git a/README.md b/README.md
index a2ce6340..c5d1764b 100644
--- a/README.md
+++ b/README.md
@@ -156,6 +156,7 @@ Transform data with NLP-backed pipelines.
| [Apply labels with zero shot classification](https://github.com/neuml/txtai/blob/master/examples/07_Apply_labels_with_zero_shot_classification.ipynb) | Use zero shot learning for labeling, classification and topic modeling | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/07_Apply_labels_with_zero_shot_classification.ipynb) |
| [Building abstractive text summaries](https://github.com/neuml/txtai/blob/master/examples/09_Building_abstractive_text_summaries.ipynb) | Run abstractive text summarization | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/09_Building_abstractive_text_summaries.ipynb) |
| [Extract text from documents](https://github.com/neuml/txtai/blob/master/examples/10_Extract_text_from_documents.ipynb) | Extract text from PDF, Office, HTML and more | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/10_Extract_text_from_documents.ipynb) |
+| [Text to speech generation](https://github.com/neuml/txtai/blob/master/examples/40_Text_to_Speech_Generation.ipynb) | Generate speech from text | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/40_Text_to_Speech_Generation.ipynb) |
| [Transcribe audio to text](https://github.com/neuml/txtai/blob/master/examples/11_Transcribe_audio_to_text.ipynb) | Convert audio files to text | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/11_Transcribe_audio_to_text.ipynb) |
| [Translate text between languages](https://github.com/neuml/txtai/blob/master/examples/12_Translate_text_between_languages.ipynb) | Streamline machine translation and language detection | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/12_Translate_text_between_languages.ipynb) |
| [Generate image captions and detect objects](https://github.com/neuml/txtai/blob/master/examples/25_Generate_image_captions_and_detect_objects.ipynb) | Captions and object detection for images | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/25_Generate_image_captions_and_detect_objects.ipynb) |
diff --git a/docs/examples.md b/docs/examples.md
index a9624580..064438d9 100644
--- a/docs/examples.md
+++ b/docs/examples.md
@@ -39,6 +39,7 @@ Transform data with NLP-backed pipelines.
| [Apply labels with zero shot classification](https://github.com/neuml/txtai/blob/master/examples/07_Apply_labels_with_zero_shot_classification.ipynb) | Use zero shot learning for labeling, classification and topic modeling | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/07_Apply_labels_with_zero_shot_classification.ipynb) |
| [Building abstractive text summaries](https://github.com/neuml/txtai/blob/master/examples/09_Building_abstractive_text_summaries.ipynb) | Run abstractive text summarization | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/09_Building_abstractive_text_summaries.ipynb) |
| [Extract text from documents](https://github.com/neuml/txtai/blob/master/examples/10_Extract_text_from_documents.ipynb) | Extract text from PDF, Office, HTML and more | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/10_Extract_text_from_documents.ipynb) |
+| [Text to speech generation](https://github.com/neuml/txtai/blob/master/examples/40_Text_to_Speech_Generation.ipynb) | Generate speech from text | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/40_Text_to_Speech_Generation.ipynb) |
| [Transcribe audio to text](https://github.com/neuml/txtai/blob/master/examples/11_Transcribe_audio_to_text.ipynb) | Convert audio files to text | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/11_Transcribe_audio_to_text.ipynb) |
| [Translate text between languages](https://github.com/neuml/txtai/blob/master/examples/12_Translate_text_between_languages.ipynb) | Streamline machine translation and language detection | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/12_Translate_text_between_languages.ipynb) |
| [Generate image captions and detect objects](https://github.com/neuml/txtai/blob/master/examples/25_Generate_image_captions_and_detect_objects.ipynb) | Captions and object detection for images | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/25_Generate_image_captions_and_detect_objects.ipynb) |
diff --git a/docs/pipeline/audio/texttospeech.md b/docs/pipeline/audio/texttospeech.md
new file mode 100644
index 00000000..43779783
--- /dev/null
+++ b/docs/pipeline/audio/texttospeech.md
@@ -0,0 +1,73 @@
+# Text To Speech
+
+![pipeline](../../images/pipeline.png#only-light)
+![pipeline](../../images/pipeline-dark.png#only-dark)
+
+The Text To Speech pipeline generates speech from text.
+
+## Example
+
+The following shows a simple example using this pipeline.
+
+```python
+from txtai.pipeline import TextToSpeech
+
+# Create and run pipeline
+tts = TextToSpeech()
+tts("Say something here")
+```
+
+See the link below for a more detailed example.
+
+| Notebook | Description | |
+|:----------|:-------------|------:|
+| [Text to speech generation](https://github.com/neuml/txtai/blob/master/examples/40_Text_to_Speech_Generation.ipynb) | Generate speech from text | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/40_Text_to_Speech_Generation.ipynb) |
+
+This pipeline is backed by ONNX models from the Hugging Face Hub. The following models are currently supported.
+
+- [ljspeech-jets-onnx](https://huggingface.co/NeuML/ljspeech-jets-onnx)
+- [ljspeech-vits-onnx](https://huggingface.co/NeuML/ljspeech-vits-onnx)
+
+## Configuration-driven example
+
+Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
+
+### config.yml
+```yaml
+# Create pipeline using lower case class name
+texttospeech:
+
+# Run pipeline with workflow
+workflow:
+ tts:
+ tasks:
+ - action: texttospeech
+```
+
+### Run with Workflows
+
+```python
+from txtai.app import Application
+
+# Create and run pipeline with workflow
+app = Application("config.yml")
+list(app.workflow("tts", ["Say something here"]))
+```
+
+### Run with API
+
+```bash
+CONFIG=config.yml uvicorn "txtai.api:app" &
+
+curl \
+ -X POST "http://localhost:8000/workflow" \
+ -H "Content-Type: application/json" \
+ -d '{"name":"tts", "elements":["Say something here"]}'
+```
+
+## Methods
+
+Python documentation for the pipeline.
+
+### ::: txtai.pipeline.TextToSpeech.__init__
+### ::: txtai.pipeline.TextToSpeech.__call__
diff --git a/docs/pipeline/index.md b/docs/pipeline/index.md
index afc21155..91b61392 100644
--- a/docs/pipeline/index.md
+++ b/docs/pipeline/index.md
@@ -12,6 +12,7 @@ Pipelines are run with Python or configuration. Pipelines can be instantiated in
The following is a list of the default pipelines available in txtai.
- Audio
+ - [TextToSpeech](audio/texttospeech)
- [Transcription](audio/transcription)
- Data Processing
- [Segmentation](data/segmentation)
diff --git a/examples/40_Text_to_Speech_Generation.ipynb b/examples/40_Text_to_Speech_Generation.ipynb
index fb97c623..114a6316 100644
--- a/examples/40_Text_to_Speech_Generation.ipynb
+++ b/examples/40_Text_to_Speech_Generation.ipynb
@@ -232,14 +232,6 @@
},
"execution_count": 56,
"outputs": [
- {
- "output_type": "stream",
- "name": "stderr",
- "text": [
- "/usr/local/lib/python3.7/dist-packages/transformers/generation_utils.py:1364: UserWarning: Neither `max_length` nor `max_new_tokens` has been set, `max_length` will default to 448 (`self.config.max_length`). Controlling `max_length` via the config is deprecated and `max_length` will be removed from the config in v5 of Transformers -- we recommend using `max_new_tokens` to control the maximum length of the generation.\n",
- " UserWarning,\n"
- ]
- },
{
"output_type": "execute_result",
"data": {
@@ -404,13 +396,6 @@
},
"execution_count": 58,
"outputs": [
- {
- "output_type": "stream",
- "name": "stderr",
- "text": [
- "INFO:tika.tika:Retrieving https://en.wikipedia.org/wiki/Natural_language_processing to /tmp/wiki-natural_language_processing.\n"
- ]
- },
{
"output_type": "display_data",
"data": {
diff --git a/mkdocs.yml b/mkdocs.yml
index ef4fb870..b08475c6 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -60,6 +60,7 @@ nav:
- Pipeline:
- pipeline/index.md
- Audio:
+ - TextToSpeech: pipeline/audio/texttospeech.md
- Transcription: pipeline/audio/transcription.md
- Data:
- Segmentation: pipeline/data/segmentation.md