Skip to content

Commit

Permalink
✨ feat: Add new files, import modules, configure themes, and update A…
Browse files Browse the repository at this point in the history
…PI endpoints

The changes include adding new files, importing modules, defining configurations, setting environment variables, configuring themes, and updating API endpoints. A new JSON file called "azureVoiceListFull.json" is added, which contains a list of voice names and locale names for different languages. The data in the file includes language codes, voice options, and neural voice models for different locales. The code also includes hooks and functions for speech synthesis and recognition, as well as a demo component. The tsconfig.json file is updated with configuration options for the TypeScript compiler.
  • Loading branch information
canisminor1990 committed Nov 7, 2023
1 parent 2088ee2 commit 9930472
Show file tree
Hide file tree
Showing 47 changed files with 4,034 additions and 71 deletions.
68 changes: 68 additions & 0 deletions .dumirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { defineConfig } from 'dumi';

import { description, homepage, name } from './package.json';

const isProduction = process.env.NODE_ENV === 'production';
const isWin = process.platform === 'win32';

const themeConfig = {
actions: [
{
link: homepage,
openExternal: true,
text: 'Github',
},
{
link: '/components/use-speech-recognition',
text: 'Get Started',
type: 'primary',
},
],
apiHeader: {
docUrl: `{github}/tree/master/src/{atomId}/index.md`,
match: ['/components'],
pkg: name,
sourceUrl: `{github}/tree/master/src/{atomId}/index.tsx`,
},
description: description,
footer: 'Made with 🤯 by LobeHub',
giscus: {
category: 'Q&A',
categoryId: 'DIC_kwDOJloKoM4CXsCu',
repo: 'lobehub/lobe-ui',
repoId: 'R_kgDOJloKoA',
},
name: 'TTS',
socialLinks: {
discord: 'https://discord.gg/AYFPHvv2jT',
github: homepage,
},
title: 'Lobe TTS',
};

export default defineConfig({
apiParser: isProduction ? {} : false,
base: '/',
define: {
'process.env': process.env,
},
favicons: ['https://npm.elemecdn.com/@lobehub/assets-favicons/assets/favicon.ico'],
locales: [{ id: 'en-US', name: 'English' }],
mfsu: isWin ? undefined : {},
npmClient: 'pnpm',
publicPath: '/',
resolve: isProduction
? {
entryFile: './src/index.ts',
}
: undefined,
styles: [
`html, body { background: transparent; }
@media (prefers-color-scheme: dark) {
html, body { background: #000; }
}`,
],
themeConfig,
title: 'Lobe TTS',
});
2 changes: 1 addition & 1 deletion .fatherrc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'father';

export default defineConfig({
cjs: { output: 'dist' },
esm: { output: 'es' },
});
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ jobs:
run: bun run release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Empty file modified .husky/commit-msg
100644 → 100755
Empty file.
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<h1>Lobe TTS</h1>

TTS API
A high-quality & reliable TTS React Hooks library

[![][github-release-shield]][github-release-link]
[![][github-releasedate-shield]][github-releasedate-link]
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions api/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import qs from 'query-string';

import cors from '../src/cors';
import { SsmlOptions } from '../src/genSSML';
import { postMicrosoftSpeech } from '../src/index';
import cors from './cors';
import { SsmlOptions } from './genSSML';
import { postMicrosoftSpeech } from './postMicrosoftSpeech';

export const config = {
runtime: 'edge',
Expand All @@ -14,6 +14,6 @@ export default async (req: Request) => {
const res = await fetch(...postMicrosoftSpeech(text, options));

const newResponse = new Response(res.body, res);

return cors(req, newResponse);
};
44 changes: 44 additions & 0 deletions api/postMicrosoftSpeech.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { v4 as uuidv4 } from 'uuid';

import { type SsmlOptions, genSSML } from './genSSML';

const API =
'https://southeastasia.api.speech.microsoft.com/accfreetrial/texttospeech/acc/v3.0-beta1/vcg/speak';

export const postMicrosoftSpeech = (text: string, options: SsmlOptions): [any, any] => {
const data = JSON.stringify({
offsetInPlainText: 0,
properties: {
SpeakTriggerSource: 'AccTuningPagePlayButton',
},
ssml: genSSML(text, options),
ttsAudioFormat: 'audio-24khz-160kbitrate-mono-mp3',
});

const DEFAULT_HEADERS = {
'accept': '*/*',
'accept-language': 'zh-CN,zh;q=0.9',
'authority': 'southeastasia.api.speech.microsoft.com',
'content-type': 'application/json',
'customvoiceconnectionid': uuidv4(),
'origin': 'https://speech.microsoft.com',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
};

return [
API,
{
body: data,
headers: DEFAULT_HEADERS,
method: 'POST',
responseType: 'arraybuffer',
},
];
};
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Changelog
description: New updates and improvements to @lobehub/ui
nav:
title: Changelog
order: 999
---

<embed src="../CHANGELOG.md"></embed>
7 changes: 7 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
hero:
title: LobeHub <b>TTS</b>
description: A high-quality & reliable TTS React Hooks library
---

<code src="./index.tsx" inline></code>
11 changes: 11 additions & 0 deletions docs/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Snippet } from '@lobehub/ui';
import { Center } from 'react-layout-kit';

export default () => {
return (
<Center style={{ marginTop: -88 }}>
<h2 style={{ fontSize: 20 }}>To install Lobe TTS, run the following command:</h2>
<Snippet language={'bash'}>{'$ bun add @lobehub/tts'}</Snippet>
</Center>
);
};
34 changes: 30 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "lobe-tts",
"name": "@lobehub/tts",
"version": "1.0.0",
"private": true,
"description": "A high-quality & reliable TTS React Hooks library",
"homepage": "https://github.com/lobehub/lobe-tts",
"bugs": {
"url": "https://github.com/lobehub/lobe-tts/issues/new/choose"
Expand All @@ -22,13 +23,18 @@
"build": "father build",
"ci": "npm run lint && npm run type-check",
"dev": "father dev",
"docs:build": "dumi build",
"docs:build-analyze": "ANALYZE=1 dumi build",
"docs:dev": "dumi dev",
"doctor": "father doctor",
"postinstall": "npm run setup",
"lint": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
"lint:md": "remark . --quiet --frail --output",
"prepare": "husky install",
"prepublishOnly": "npm run build",
"prettier": "prettier -c --write \"**/**\"",
"release": "semantic-release",
"setup": "dumi setup",
"start": "vercel dev",
"type-check": "tsc --noEmit"
},
Expand All @@ -55,26 +61,46 @@
"not ie <= 10"
],
"dependencies": {
"lodash-es": "^4",
"microsoft-cognitiveservices-speech-sdk": "^1",
"query-string": "^8",
"ssml-document": "^1",
"swr": "^2",
"uuid": "^9"
},
"devDependencies": {
"@commitlint/cli": "^18",
"@lobehub/lint": "latest",
"@lobehub/ui": "latest",
"@types/lodash-es": "^4",
"@types/node": "^20",
"@types/query-string": "^6",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/uuid": "^9",
"@vercel/node": "^3.0.7",
"@vercel/node": "^3",
"commitlint": "^18",
"dumi": "^2",
"dumi-theme-lobehub": "latest",
"eslint": "^8",
"father": "4.3.1",
"father": "4",
"husky": "^8",
"lint-staged": "^15",
"lucide-react": "latest",
"prettier": "^3",
"react": "^18",
"react-dom": "^18",
"react-layout-kit": "^1",
"remark": "^14",
"remark-cli": "^11",
"semantic-release": "^21",
"typescript": "^5",
"vercel": "^28.20.0"
"vercel": "^28"
},
"peerDependencies": {
"antd": ">=5",
"react": ">=18",
"react-dom": ">=18"
},
"publishConfig": {
"access": "public",
Expand Down
8 changes: 0 additions & 8 deletions public/index.html

This file was deleted.

13 changes: 13 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"automerge": false,
"dependencyDashboard": true,
"ignoreDeps": [],
"labels": ["dependencies"],
"postUpdateOptions": ["yarnDedupeHighest"],
"prConcurrentLimit": 30,
"prHourlyLimit": 0,
"rebaseWhen": "conflicted",
"schedule": "on sunday before 6:00am",
"timezone": "UTC"
}
Loading

0 comments on commit 9930472

Please sign in to comment.