-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add text-to-speech functionality #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0d4a743
Add text-to-speech functionality
heyseth 4cd5545
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth 8d98ce6
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth 1a47e9d
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth 88cf106
Add speed config option to text-to-speech
heyseth 8f19387
Fix test case for tts speed slider
heyseth a734d51
Fix test case for tts speed slider (really)
heyseth be9e57e
Disabled error message logging in tts.ts
heyseth 409d67c
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth da8a98c
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth 0b716f2
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth 2223762
Merge branch 'RooVetGit:main' into feature/textToSpeech
heyseth 1b6b830
ignore markdown and mermaid diagrams in TTS
heyseth b4eed3f
Merge branch 'feature/textToSpeech' of https://github.com/heyseth/Roo…
heyseth 552022d
add ttsEnabled and ttsSpeed to GlobalStateKey
heyseth 5f32cb9
Merge remote-tracking branch 'upstream/main' into feature/textToSpeech
heyseth 1d7de4b
fix failing webview test for save button
heyseth 63d6d64
Merge remote-tracking branch 'origin/main' into feature/textToSpeech
mrubens d867e0e
Translations
mrubens 730548e
Fix tests
mrubens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,75 @@ | ||
| import * as vscode from "vscode" | ||
|
|
||
| let isTtsEnabled = false | ||
| let speed = 1.0 | ||
| let isSpeaking = false | ||
| const utteranceQueue: string[] = [] | ||
|
|
||
| /** | ||
| * Set tts configuration | ||
| * @param enabled boolean | ||
| */ | ||
| export const setTtsEnabled = (enabled: boolean): void => { | ||
| isTtsEnabled = enabled | ||
| } | ||
|
|
||
| /** | ||
| * Set tts speed | ||
| * @param speed number | ||
| */ | ||
| export const setTtsSpeed = (newSpeed: number): void => { | ||
| speed = newSpeed | ||
| } | ||
|
|
||
| /** | ||
| * Process the next item in the utterance queue | ||
| */ | ||
| const processQueue = async (): Promise<void> => { | ||
| if (!isTtsEnabled || isSpeaking || utteranceQueue.length === 0) { | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| isSpeaking = true | ||
| const nextUtterance = utteranceQueue.shift()! | ||
| const say = require("say") | ||
|
|
||
| // Wrap say.speak in a promise to handle completion | ||
| await new Promise<void>((resolve, reject) => { | ||
| say.speak(nextUtterance, null, speed, (err: Error) => { | ||
| if (err) { | ||
| reject(err) | ||
| } else { | ||
| resolve() | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| isSpeaking = false | ||
| // Process next item in queue if any | ||
| await processQueue() | ||
| } catch (error: any) { | ||
| isSpeaking = false | ||
| //vscode.window.showErrorMessage(error.message) | ||
| // Try to continue with next item despite error | ||
| await processQueue() | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Queue a tts message to be spoken | ||
| * @param message string | ||
| * @return void | ||
| */ | ||
| export const playTts = async (message: string): Promise<void> => { | ||
| if (!isTtsEnabled) { | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| utteranceQueue.push(message) | ||
| await processQueue() | ||
| } catch (error: any) { | ||
| //vscode.window.showErrorMessage(error.message) | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.