Skip to content

Commit

Permalink
Merge pull request #279 from appwrite/feat-lmnt
Browse files Browse the repository at this point in the history
Add LMNT Demo
  • Loading branch information
christyjacob4 authored May 3, 2024
2 parents a6a2c2a + 6a0c398 commit 8beb30f
Show file tree
Hide file tree
Showing 7 changed files with 898 additions and 0 deletions.
104 changes: 104 additions & 0 deletions node/speak-with-lmnt/README.md
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) |
12 changes: 12 additions & 0 deletions node/speak-with-lmnt/env.d.ts
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 {};
Loading

0 comments on commit 8beb30f

Please sign in to comment.