Skip to main content

langchain-flowspeech

LangChain tools for FlowSpeech public API v1.

pip install langchain-flowspeech==0.2.0

Set FLOWSPEECH_API_KEY in your server environment, then:

from langchain_flowspeech import FlowSpeechTextToSpeechTool

tool = FlowSpeechTextToSpeechTool(timeout=300)
try:
    result = tool.invoke({
        "text": "Welcome.[pause:2s]Let's begin.",
        "voice_name": "Kore",
        "output_path": "speech.wav",
    })
    print(result["job_id"], result["request_id"], result["usage"])
finally:
    tool.close()

Async callers can use await tool.ainvoke(...) with the same arguments and result. FlowSpeechClient also provides agenerate_speech, acheck_quota and alist_voices. These offload synchronous I/O to a worker thread; cancelling the await does not cancel the server job or immediately stop the worker. The configured deadline still bounds its work. Explicit cancel_job is available.

Multi-speaker input

from langchain_flowspeech import FlowSpeechClient

with FlowSpeechClient() as client:
    result = client.generate_speech(segments=[
        {"speaker": "Alice", "text": "Welcome.", "voiceName": "Kore"},
        {"speaker": "Bob", "text": "Thank you.", "voiceName": "Puck"},
    ])
    result.save("conversation.wav")
    print(client.check_quota().available)
    print(client.list_voices())

Legacy speakers assignments remain supported when every nonblank text line has the form Label: utterance. Unknown/duplicate labels or unlabelled lines are rejected; use segments for arbitrary multiline scripts. One unlabelled voice assignment maps to single mode. original_text is accepted only when identical to text.

FlowSpeechTtsResult.audio_base64 remains available for compatibility but is encoded locally from downloaded WAV bytes. The API itself does not return base64. The legacy result quota field is None; use usage for this job or check_quota() for a current account balance. Legacy limit/used/reset_at/is_guest fields are None.

Pass request_id to reuse the UUID only with unchanged input. After a timeout use client.find_job(request_id), then client.get_job(job_id); for download failures, client.download_audio(result_url) downloads again without generation.

API v1 behavior

An active paid Basic, Pro or Scale subscription and a FlowSpeech API key are required; trials do not include API generation. Keep FLOWSPEECH_API_KEY server-side. See public API documentation.

Generation submits POST /api/v1/tts/jobs with {"input": ...} and one UUID Idempotency-Key, waits through queued/running/merging/settling, then downloads result.url after success. A 200 response alone does not mean generation succeeded. Single input uses mode/text/voiceName. Multi input uses mode/segments, where each turn contains speaker, text and voiceName. Model, source, speed and format options are unsupported and must not be sent.

The default total deadline is 300 seconds, polling is at least five seconds, and longer Retry-After values (seconds or HTTP dates) are honored. Transient transport failures, 429, and explicitly retryable 5xx errors get at most two retries. Create retries preserve the UUID and exact body. A deadline stops local waiting, not the server job; use the saved IDs for recovery or explicit cancellation.

Errors expose status_code, code, retryable, trace_id, request_id, job_id and result_url where available. Failed and cancelled jobs raise errors. Deleted success results are reported as result_deleted, not as empty audio.

Audio is a separately downloaded, validated WAV (24000 Hz, mono, 16 bit). Validation checks the entire RIFF size, chunk bounds/padding, exactly one PCM format/data pair, byte rate 48000, block alignment 2 and nonempty complete samples. Malformed audio raises invalid_audio with request/job IDs and the existing result URL preserved; it does not trigger another recording. Downloads use HTTPS without API Authorization, cookies, or default client credentials, including across redirects. API redirects are rejected. Downloads are bounded to 64 MiB by default. A download retry never submits another recording. Anyone holding a result URL can access the recording; treat links as sensitive.

GET /api/v1/quota returns quota.remaining/reserved/available plus subscription and limits. GET /api/v1/voices returns voices. Recovery uses GET /api/v1/tts/jobs?requestId=UUID; status and cancel use /api/v1/tts/jobs/{UUID} and /api/v1/tts/jobs/{UUID}/cancel.

Development

python -m pip install -e ".[test]" build
python -m pytest -q
python -m build

Tests use fake HTTP transports and synthetic WAVs. No production generation. See RELEASE.md for coordinator-only release instructions.

Metadata

Release files for langchain-flowspeech 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-flowspeech 0.2.0
File Size Uploaded Provenance Actions
langchain_flowspeech-0.2.0.tar.gz 22.6 kB With provenance Details for langchain_flowspeech-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-flowspeech 0.2.0
File Interpreter ABI Platform Actions
langchain_flowspeech-0.2.0-py3-none-any.whl Python 3 none any Details for langchain_flowspeech-0.2.0-py3-none-any.whl

Total release size: 36.3 kB

Release files / langchain_flowspeech-0.2.0.tar.gz

Download URL langchain_flowspeech-0.2.0.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3dce57f7ce7031d5c115b39e8fc892b433a12ec5b8610c68243d91b220384a5f
BLAKE2b-256 checksum
How to use checksums
865cc5fd329d2bc8c17a45b0feb1c7e42702fad2462f8b37a9d16b3abe84b95b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / langchain_flowspeech-0.2.0-py3-none-any.whl

Download URL langchain_flowspeech-0.2.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d7e9fecba7bf660da093ea351858f9c90e6c4d9df8b24b8899648d704625add
BLAKE2b-256 checksum
How to use checksums
1b209c7882c3297e16de64110d847ec2a956defa7f64f8d0fb1654dfb610c10c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for langchain-flowspeech 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_flowspeech-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page