docs: add examples

This commit is contained in:
藍+85CD committed 2025-03-02 17:28:58 +08:00
1 parent 597b7e49fe
commit d4e7d79255
5 files changed
+39 -2

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ words:
- eslintcache
- fishaudio
- fumadocs
- ggml
- Groq
- Hunyuan
- importantimport
+17 -1
View File
@@ -1,6 +1,6 @@
---
title: Speech (WIP)
# description:
description: Generates audio from the input text.
---
import { PkgSizeBadge } from '@/components/pkg-size-badge'
@@ -10,3 +10,19 @@ import { PkgSizeBadge } from '@/components/pkg-size-badge'
```package-install
npm i @xsai/generate-speech
```
## Examples
```ts twoslash
import { generateSpeech } from '@xsai/generate-speech'
import { Buffer } from 'node:buffer'
const speech = await generateSpeech({
baseURL: 'http://localhost:5050',
input: 'Hello, I am your AI assistant! Just let me know how I can help bring your ideas to life.',
model: 'tts-1',
voice: 'en-US-AnaNeural',
})
const audio = Buffer.from(speech)
```
@@ -11,6 +11,8 @@ import { PkgSizeBadge } from '@/components/pkg-size-badge'
npm i @xsai/generate-text
```
## Examples
```ts twoslash
import { generateText } from '@xsai/generate-text'
import { env } from 'node:process'
@@ -1,6 +1,6 @@
---
title: Transcription (WIP)
# description:
description: Transcribes audio into the input language.
---
import { PkgSizeBadge } from '@/components/pkg-size-badge'
@@ -10,3 +10,19 @@ import { PkgSizeBadge } from '@/components/pkg-size-badge'
```package-install
npm i @xsai/generate-transcription
```
## Examples
```ts twoslash
import { generateTranscription } from '@xsai/generate-transcription'
import { openAsBlob } from 'node:fs'
const { text } = await generateTranscription({
apiKey: '',
baseURL: 'http://localhost:9010',
file: await openAsBlob('./test/fixtures/basic.wav', { type: 'audio/wav' }),
fileName: 'basic.wav',
language: 'en-US',
model: 'ggml-large-v3-turbo-q5_0.bin',
})
```
@@ -11,6 +11,8 @@ import { PkgSizeBadge } from '@/components/pkg-size-badge'
npm i @xsai/stream-text
```
## Examples
```ts twoslash
import { streamText } from '@xsai/stream-text'
import { env } from 'node:process'