Skip to content
Merged
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
8 changes: 4 additions & 4 deletions agents/python-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name = "audio-python-quickstart"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = [
"speechify-api>=2.0.0",
"speechify-api>=3.0.1",
"python-dotenv>=1.0.0",
]
```
Expand All @@ -43,11 +43,11 @@ from speechify import Speechify

load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (see .env.example).")

client = Speechify(api_key=api_key)
client = Speechify(token=token)
```

An async variant is available as `AsyncSpeechify` with identical method signatures.
Expand Down
8 changes: 4 additions & 4 deletions agents/speechify-tts.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Both SDKs read `SPEECHIFY_API_KEY` from the environment. The deprecated

## Synthesize speech

**TypeScript** (`@speechify/api` v2)
**TypeScript** (`@speechify/api` v3)

```ts
import { SpeechifyClient } from "@speechify/api";

const client = new SpeechifyClient({ apiKey: process.env.SPEECHIFY_API_KEY! });
const client = new SpeechifyClient({ token: process.env.SPEECHIFY_API_KEY! });

const response = await client.audio.speech({
input: "Hello! This is the Speechify text-to-speech API.",
Expand All @@ -34,12 +34,12 @@ import fs from "node:fs";
fs.writeFileSync("output.mp3", Buffer.from(response.audio_data, "base64"));
```

**Python** (`speechify-api` v2)
**Python** (`speechify-api` v3)

```python
from speechify import Speechify

client = Speechify(api_key=api_key)
client = Speechify(token=token)

response = client.audio.speech(
input="Hello! This is the Speechify text-to-speech API.",
Expand Down
2 changes: 1 addition & 1 deletion agents/typescript-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (!process.env.SPEECHIFY_API_KEY) {
throw new Error("Set SPEECHIFY_API_KEY (see .env.example).");
}

const client = new SpeechifyClient({ apiKey: process.env.SPEECHIFY_API_KEY });
const client = new SpeechifyClient({ token: process.env.SPEECHIFY_API_KEY });
```

## Style
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages:
# Single source of truth for shared dependency versions.
# Recipes reference these with "catalog:" instead of pinning their own.
catalog:
"@speechify/api": 2.0.0
"@speechify/api": 3.0.1
tsx: ^4.19.2
typescript: ^5.7.2
"@types/node": ^22.10.2
Expand Down
6 changes: 3 additions & 3 deletions recipes/audio/python/native/quickstart/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

resp = requests.post(
"https://api.speechify.ai/v1/audio/speech",
headers={
"Authorization": f"Bearer {api_key}",
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
json={
Expand Down
6 changes: 3 additions & 3 deletions recipes/audio/python/native/speech-marks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def vtt_time(ms: int) -> str:
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

resp = requests.post(
"https://api.speechify.ai/v1/audio/speech",
headers={
"Authorization": f"Bearer {api_key}",
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
json={
Expand Down
6 changes: 3 additions & 3 deletions recipes/audio/python/native/ssml-emotion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

resp = requests.post(
"https://api.speechify.ai/v1/audio/speech",
headers={
"Authorization": f"Bearer {api_key}",
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
json={
Expand Down
6 changes: 3 additions & 3 deletions recipes/audio/python/native/streaming/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

# POST /v1/audio/stream returns raw audio bytes (HTTP chunked) instead of
Expand All @@ -20,7 +20,7 @@ def main() -> None:
with requests.post(
"https://api.speechify.ai/v1/audio/stream",
headers={
"Authorization": f"Bearer {api_key}",
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
"Accept": "audio/mpeg",
},
Expand Down
6 changes: 3 additions & 3 deletions recipes/audio/python/native/voice-cloning/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

auth = {"Authorization": f"Bearer {api_key}"}
auth = {"Authorization": f"Bearer {token}"}

# 1. Clone a voice from an audio sample (10-30s of clean speech works well).
# POST /v1/voices is multipart/form-data — pass `files=` to requests and it
Expand Down
6 changes: 3 additions & 3 deletions recipes/audio/python/sdk/quickstart/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

client = Speechify(api_key=api_key)
client = Speechify(token=token)

response = client.audio.speech(
input="Hello! This is the Speechify text-to-speech API.",
Expand Down
2 changes: 1 addition & 1 deletion recipes/audio/python/sdk/quickstart/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
description = "Synthesize speech to an MP3 file with the Speechify TTS API."
requires-python = ">=3.10"
dependencies = [
"speechify-api>=2.0.0",
"speechify-api>=3.0.1",
"python-dotenv>=1.0.0",
]
8 changes: 4 additions & 4 deletions recipes/audio/python/sdk/quickstart/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions recipes/audio/python/sdk/speech-marks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def vtt_time(ms: int) -> str:
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

client = Speechify(api_key=api_key)
client = Speechify(token=token)

response = client.audio.speech(
input="The quick brown fox jumps over the lazy dog.",
Expand Down
2 changes: 1 addition & 1 deletion recipes/audio/python/sdk/speech-marks/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
description = "Generate WebVTT captions from word-level speech marks with the Speechify TTS API."
requires-python = ">=3.10"
dependencies = [
"speechify-api>=2.0.0",
"speechify-api>=3.0.1",
"python-dotenv>=1.0.0",
]
8 changes: 4 additions & 4 deletions recipes/audio/python/sdk/speech-marks/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions recipes/audio/python/sdk/ssml-emotion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
def main() -> None:
load_dotenv()

api_key = os.environ.get("SPEECHIFY_API_KEY")
if not api_key:
token = os.environ.get("SPEECHIFY_API_KEY")
if not token:
raise SystemExit("Set SPEECHIFY_API_KEY (copy .env.example to .env).")

client = Speechify(api_key=api_key)
client = Speechify(token=token)

response = client.audio.speech(
input=SSML,
Expand Down
2 changes: 1 addition & 1 deletion recipes/audio/python/sdk/ssml-emotion/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
description = "Control emotion, pitch, rate, pauses & emphasis via SSML with the Speechify TTS API."
requires-python = ">=3.10"
dependencies = [
"speechify-api>=2.0.0",
"speechify-api>=3.0.1",
"python-dotenv>=1.0.0",
]
8 changes: 4 additions & 4 deletions recipes/audio/python/sdk/ssml-emotion/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading