Skip to content

Issue #214481: Add option to filter code from copilot chat text to speech#230012

Closed
burkus wants to merge 12 commits intomicrosoft:mainfrom
burkus:main
Closed

Issue #214481: Add option to filter code from copilot chat text to speech#230012
burkus wants to merge 12 commits intomicrosoft:mainfrom
burkus:main

Conversation

@burkus
Copy link

@burkus burkus commented Sep 27, 2024

This is an implementation of a requested feature issued here: #214481

I've added a new option to the accessibility.voice.* options, called 'FilterCode'.
It is enabled by default.
When on, it filters out code blocks delimited by triple backticks "```" so that text to speech doesn't sound spammy/annoying when it contains large amounts of code.

I was hoping to do this as part of Hacktoberfest

@burkus
Copy link
Author

burkus commented Sep 27, 2024

@bpasero thanks for your help!

@burkus burkus changed the title Issue #214481: Add option to filter code from copilot chat text to speech, #214481 Issue #214481: Add option to filter code from copilot chat text to speech Sep 27, 2024
@burkus
Copy link
Author

burkus commented Sep 27, 2024

@microsoft-github-policy-service agree

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not needed for this task?

localize('accessibility.voice.autoSynthesize.on', "Enable the feature. When a screen reader is enabled, note that this will disable aria updates."),
localize('accessibility.voice.autoSynthesize.off', "Disable the feature."),
localize('accessibility.voice.autoSynthesize.auto', "When a screen reader is detected, disable the feature. Otherwise, enable the feature.")
localize('accessibility.voice.autoSynthesize.auto', "When a screen reader is detected, disable the feature. Otherwise, enable the feature."),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

SpeechTimeout = 'accessibility.voice.speechTimeout',
AutoSynthesize = 'accessibility.voice.autoSynthesize',
SpeechLanguage = 'accessibility.voice.speechLanguage',
FilterCode = 'accessibility.voice.filterCode'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about accessibility.voice.ignoreCodeBlocks

let chunk: string | undefined = undefined;

const text = response.response.toString();
const filter = this.configurationService.getValue<boolean>(AccessibilityVoiceSettingId.FilterCode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now that I see this, I would suggest to filter code blocks here in voiceChatActions and not introduce changes to chatModel.

One thing to address: we receive chunks from the chat model and we may actually be inside a code block, so the logic to filter out code blocks needs to track if we are currently inside a code block I think and then keep ignoring the chunk until the code block is exited.

Comment on lines +859 to +876
const ignoreCodeBlocks = this.configurationService.getValue<boolean>(AccessibilityVoiceSettingId.IgnoreCodeBlocks);
let text = response.response.toString();
const delimiter = '```';
let codeBlockTerminates = false;
const firstDelimiterIndex = text.indexOf(delimiter);

if (ignoreCodeBlocks && isWithinCodeBlock && firstDelimiterIndex === -1) {
text = '';
} else if (ignoreCodeBlocks && !isWithinCodeBlock) {
const [filteredText, terminated] = this.withoutCodeBlocks(text);
text = filteredText;
codeBlockTerminates = terminated;
} else if (ignoreCodeBlocks && isWithinCodeBlock && firstDelimiterIndex >= 0) {
text = text.substring(firstDelimiterIndex + 1);
const [filteredText, terminated] = this.withoutCodeBlocks(text);
text = filteredText;
codeBlockTerminates = terminated;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpasero hope I didn't overcomplicate it

@bpasero
Copy link
Member

bpasero commented Dec 11, 2024

Going with #235697, thanks though, much appreciated!

@bpasero bpasero closed this Dec 11, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants