Skip to content

Commit

Permalink
fix: @lobehub/tts useSpeechSynthes (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
dayuy authored Oct 11, 2024
1 parent 67edfca commit 50b42d3
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yuntijs/ui",
"version": "1.0.0-beta.67",
"version": "1.0.0-beta.68",
"description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
"keywords": [
"yuntijs",
Expand Down Expand Up @@ -86,6 +86,7 @@
"@lexical/selection": "^0.16.1",
"@lexical/text": "^0.16.1",
"@lexical/utils": "^0.16.1",
"@lobehub/tts": "^1.25.1",
"@lobehub/ui": "^1.147.0",
"@melloware/react-logviewer": "^5.2.0",
"@monaco-editor/loader": "^1.4.0",
Expand Down
124 changes: 118 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export * from './EditableMessage';
export * from './Highlighter';
export * from './styles';

// ~ custom @lobehub/tts
export * from './useSpeechSynthes';

// ~ antd
export {
Affix,
Expand Down
32 changes: 32 additions & 0 deletions src/useSpeechSynthes/const/polyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const getSpeechRecognition = () => {
try {
return (
(globalThis as any)?.SpeechRecognition ||
(window as any)?.SpeechRecognition ||
(window as any)?.webkitSpeechRecognition
);
} catch {}
};

const getSpeechSynthesis = () => {
try {
return (
(globalThis as any)?.speechSynthesis ||
(window as any)?.speechSynthesis ||
(window as any)?.webkitSpeechSynthesis
);
} catch {}
};

const getSpeechSynthesisUtterance = () => {
try {
return (
(globalThis as any)?.SpeechSynthesisUtterance ||
(window as any)?.SpeechSynthesisUtterance ||
(window as any)?.webkitSpeechSynthesisUtterance
);
} catch {}
};
export const SpeechRecognition = getSpeechRecognition();
export const SpeechSynthesis = getSpeechSynthesis();
export const SpeechSynthesisUtterance = getSpeechSynthesisUtterance();
Loading

0 comments on commit 50b42d3

Please sign in to comment.