Skip to content

Commit 378b5f6

Browse files
committed
Release 0.0.129
0 parents  commit 378b5f6

File tree

271 files changed

+12427
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+12427
-0
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ci
2+
3+
on: [push]
4+
5+
jobs:
6+
compile:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v3
12+
13+
- name: Set up node
14+
uses: actions/setup-node@v3
15+
16+
- name: Compile
17+
run: yarn && yarn build
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
26+
- name: Set up node
27+
uses: actions/setup-node@v3
28+
29+
- name: Compile
30+
run: yarn && yarn test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
/dist

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
src
3+
tests
4+
.gitignore
5+
.github
6+
.fernignore
7+
.prettierrc.yml
8+
tsconfig.json
9+
yarn.lock

.prettierrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tabWidth: 4
2+
printWidth: 120

README.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Speechifyinc TypeScript Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fspeechifyinc%2Fspeechify-api-sdk-typescript)
4+
[![npm shield](https://img.shields.io/npm/v/)](https://www.npmjs.com/package/)
5+
6+
The Speechifyinc TypeScript library provides convenient access to the Speechifyinc API from TypeScript.
7+
8+
## Installation
9+
10+
```sh
11+
npm i -s
12+
```
13+
14+
## Reference
15+
16+
A full reference for this library is available [here](./reference.md).
17+
18+
## Usage
19+
20+
Instantiate and use the client with the following:
21+
22+
```typescript
23+
import { SpeechifyClient } from "";
24+
25+
const client = new SpeechifyClient({ token: "YOUR_TOKEN" });
26+
await client.tts.audio.speech({
27+
input: "input",
28+
voiceId: "voice_id",
29+
});
30+
```
31+
32+
## Request And Response Types
33+
34+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
35+
following namespace:
36+
37+
```typescript
38+
import { Speechify } from "Speechify";
39+
40+
const request: Speechify.GetSpeechRequest = {
41+
...
42+
};
43+
```
44+
45+
## Exception Handling
46+
47+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
48+
will be thrown.
49+
50+
```typescript
51+
import { SpeechifyError } from "Speechify";
52+
53+
try {
54+
await client.tts.audio.speech(...);
55+
} catch (err) {
56+
if (err instanceof SpeechifyError) {
57+
console.log(err.statusCode);
58+
console.log(err.message);
59+
console.log(err.body);
60+
}
61+
}
62+
```
63+
64+
## Advanced
65+
66+
### Additional Headers
67+
68+
If you would like to send additional headers as part of the request, use the `headers` request option.
69+
70+
```typescript
71+
const response = await client.tts.audio.speech(..., {
72+
headers: {
73+
'X-Custom-Header': 'custom value'
74+
}
75+
});
76+
```
77+
78+
### Retries
79+
80+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
81+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
82+
retry limit (default: 2).
83+
84+
A request is deemed retryable when any of the following HTTP status codes is returned:
85+
86+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
87+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
88+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
89+
90+
Use the `maxRetries` request option to configure this behavior.
91+
92+
```typescript
93+
const response = await client.tts.audio.speech(..., {
94+
maxRetries: 0 // override maxRetries at the request level
95+
});
96+
```
97+
98+
### Timeouts
99+
100+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
101+
102+
```typescript
103+
const response = await client.tts.audio.speech(..., {
104+
timeoutInSeconds: 30 // override timeout to 30s
105+
});
106+
```
107+
108+
### Aborting Requests
109+
110+
The SDK allows users to abort requests at any point by passing in an abort signal.
111+
112+
```typescript
113+
const controller = new AbortController();
114+
const response = await client.tts.audio.speech(..., {
115+
abortSignal: controller.signal
116+
});
117+
controller.abort(); // aborts the request
118+
```
119+
120+
### Runtime Compatibility
121+
122+
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
123+
runtimes:
124+
125+
- Node.js 18+
126+
- Vercel
127+
- Cloudflare Workers
128+
- Deno v1.25+
129+
- Bun 1.0+
130+
- React Native
131+
132+
### Customizing Fetch Client
133+
134+
The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an
135+
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
136+
137+
```typescript
138+
import { SpeechifyClient } from "Speechify";
139+
140+
const client = new SpeechifyClient({
141+
...
142+
fetcher: // provide your implementation here
143+
});
144+
```
145+
146+
## Contributing
147+
148+
While we value open-source contributions to this SDK, this library is generated programmatically.
149+
Additions made directly to this library would have to be moved over to our generation code,
150+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
151+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
152+
an issue first to discuss with us!
153+
154+
On the other hand, contributions to the README are always very welcome!

jest.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('jest').Config} */
2+
export default {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
moduleNameMapper: {
6+
"(.+)\.js$": "$1",
7+
},
8+
};

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "",
3+
"version": "0.0.129",
4+
"private": false,
5+
"repository": "https://github.com/speechifyinc/speechify-api-sdk-typescript",
6+
"main": "./index.js",
7+
"types": "./index.d.ts",
8+
"scripts": {
9+
"format": "prettier . --write --ignore-unknown",
10+
"build": "tsc",
11+
"prepack": "cp -rv dist/. .",
12+
"test": "jest"
13+
},
14+
"dependencies": {
15+
"url-join": "4.0.1",
16+
"form-data": "^4.0.0",
17+
"formdata-node": "^6.0.3",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
20+
"readable-stream": "^4.5.2",
21+
"js-base64": "3.7.7",
22+
"form-data-encoder": "^4.0.2"
23+
},
24+
"devDependencies": {
25+
"@types/url-join": "4.0.1",
26+
"@types/qs": "^6.9.17",
27+
"@types/node-fetch": "^2.6.12",
28+
"@types/readable-stream": "^4.0.18",
29+
"webpack": "^5.97.1",
30+
"ts-loader": "^9.5.1",
31+
"jest": "^29.7.0",
32+
"@types/jest": "^29.5.14",
33+
"ts-jest": "^29.1.1",
34+
"jest-environment-jsdom": "^29.7.0",
35+
"@types/node": "^18.19.70",
36+
"prettier": "^3.4.2",
37+
"typescript": "~5.7.2"
38+
},
39+
"browser": {
40+
"fs": false,
41+
"os": false,
42+
"path": false
43+
}
44+
}

0 commit comments

Comments
 (0)