-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from appwrite/feat-lmnt
Add LMNT Demo
- Loading branch information
Showing
7 changed files
with
898 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# 📣 Node Speak with LMNT Function | ||
|
||
Turn text into speech using the LMNT API and save the audio file to Appwrite storage while outputting a link to the file. | ||
|
||
## 🧰 Usage | ||
|
||
### GET / | ||
|
||
HTML form for interacting with the function. | ||
|
||
### POST / | ||
|
||
Query the model for a completion. | ||
|
||
**Parameters** | ||
|
||
| Name | Description | Location | Type | Sample Value | Required | | ||
| ------------ | --------------------------------------------------------------------------------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------- | | ||
| Content-Type | The content type of the request body | Header | `application/json` | N/A | Yes | | ||
| text | Text for the model to say | Body | String | ` Appwrite is a secure backend server for web, mobile, and Flutter apps, providing easy setup for database, authentication, storage, and more.` | Yes | | ||
|
||
Sample `200` Response: | ||
|
||
Response from the model. | ||
|
||
```json | ||
{ | ||
"ok": true, | ||
"response": "https://cloud.appwrite.io/v1/storage/buckets/text_to_speech/files/66019da664270f02c20c/view?project=project_id" | ||
} | ||
``` | ||
|
||
Sample `400` Response: | ||
|
||
Response when the request body is missing. | ||
|
||
```json | ||
{ | ||
"ok": false, | ||
"error": "Missing body with a prompt." | ||
} | ||
``` | ||
|
||
Sample `500` Response: | ||
|
||
Response when the model fails to respond. | ||
|
||
```json | ||
{ | ||
"ok": false, | ||
"error": "Failed to query model." | ||
} | ||
``` | ||
|
||
## ⚙️ Configuration | ||
|
||
| Setting | Value | | ||
| ----------------- | ------------- | | ||
| Runtime | Node (18.0) | | ||
| Entrypoint | `src/main.js` | | ||
| Build Commands | `npm install` | | ||
| Permissions | `any` | | ||
| Timeout (Seconds) | 60 | | ||
|
||
## 🔒 Environment Variables | ||
|
||
### LMNT_API_KEY | ||
|
||
A unique key used to authenticate with the LMNT API. You can find your API key in the LMNT dashboard. | ||
|
||
| Question | Answer | | ||
| ------------- | --------------------------------------------------------------------------- | | ||
| Required | Yes | | ||
| Sample Value | `d03xxxxxxxx26` | | ||
| Documentation | [LMNT Docs](https://docs.lmnt.com/getting-started/environment-setup) | | ||
|
||
### APPWRITE_ENDPOINT | ||
|
||
The endpoint of the Appwrite API. | ||
|
||
| Question | Answer | | ||
| ------------- | ------------------------------ | | ||
| Required | No | | ||
| Default Value | `https://cloud.appwrite.io/v1` | | ||
|
||
### APPWRITE_API_KEY | ||
|
||
A unique key used to authenticate with the Appwrite API. You can generate your API key in the Appwrite dashboard. It must have the `files.read` and `files.write` permissions. | ||
|
||
| Question | Answer | | ||
| ------------- | -------------------------------------------------------------------- | | ||
| Required | Yes | | ||
| Sample Value | `631xxxxxxxx8a` | | ||
| Documentation | [Appwrite Docs](https://appwrite.io/docs/advanced/platform/api-keys) | | ||
|
||
### APPWRITE_BUCKET_ID | ||
|
||
The ID of the Appwrite storage bucket where the audio files will be saved. | ||
|
||
| Question | Answer | | ||
| ------------- | ------------------------------------------------------------------ | | ||
| Required | Yes | | ||
| Sample Value | `66019da664270f02c20c` | | ||
| Documentation | [Appwrite Docs](https://appwrite.io/docs/products/storage/buckets) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
declare global { | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
LMNT_API_KEY: string; | ||
APPWRITE_BUCKET_ID: string; | ||
APPWRITE_API_KEY: string; | ||
APPWRITE_ENDPOINT: string; | ||
} | ||
} | ||
} | ||
|
||
export {}; |
Oops, something went wrong.