Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ There's also more control of text generation via the Text-generator API, this in
* max_sentences (generate only a set number of sentences at most)

Text generator also has routes for speech to text and speech generation.
You can now stream generated speech in real time via `/api/v1/generate_speech_stream`.

See https://text-generator.io/docs

Expand Down
16 changes: 16 additions & 0 deletions apiexamples/streaming_speech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import requests
import os

API_KEY = os.getenv("TEXT_GENERATOR_API_KEY")
if API_KEY is None:
raise Exception(
"Please set TEXT_GENERATOR_API_KEY environment variable, login to https://text-generator.io to get your API key")
headers = {"secret": API_KEY}

params = {
"text": "Hello streaming world",
"speaker": "Male fast"
}
with requests.post("https://api.text-generator.io/api/v1/generate_speech_stream", json=params, headers=headers, stream=True) as r:
for chunk in r.iter_content(chunk_size=None):
print("Received", len(chunk), "bytes")
5 changes: 5 additions & 0 deletions questions/blog_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@
"description": "Control summary length precisely by specifying maximum characters in the summarization API",
"keywords": "text summarization, API, natural language processing, text generation, Machine Learning"
},
"streaming-speech-api": {
"title": "Stream Speech Output in Real Time",
"description": "Generate speech in chunks and stream it directly without buffering the whole audio.",
"keywords": "text to speech, streaming, API"
},
}
Loading