Skip to content

Commit

Permalink
fix: trigger removal
Browse files Browse the repository at this point in the history
  • Loading branch information
idosal committed Dec 11, 2022
1 parent 6f86db1 commit e11c247
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Popup() {
return <main>
<MessageList style={{ display: "flex" }} ref={ msgListRef }>
<Message model={{
message: "Hello! I'm your ChatGPT assistant. To start, simply say \"Hey girl\", followed by your prompt.",
message: "Hello! I'm your ChatGPT assistant. To start, simply say \"Hey girl\" (or your custom trigger), followed by your prompt.",
position: 'single',
direction: 'incoming',
}} />
Expand Down
12 changes: 6 additions & 6 deletions src/content/audio.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,19 @@ try {
const transcript = event.results[event.results?.length - 1][0].transcript
console.log(transcript)
if (isActive) {
let instruction = transcript
if (transcript.trimStart().startsWith(triggerPhrase)) {
instruction = transcript.trimStart().substring(triggerPhrase.length)
}
isActive = false
getAnswer(transcript)
getAnswer(instruction)
return
}

const trimmed = transcript.trimStart().trimEnd().toLowerCase()
if (trimmed.startsWith(triggerPhrase)) {
let instruction = trimmed.substring(triggerPhrase.length)
const instruction = trimmed.substring(triggerPhrase.length)
if (instruction && instruction?.length > 2) {
if (instruction.startsWith(triggerPhrase)) {
instruction = instruction.substring(triggerPhrase.length)
}

getAnswer(instruction)
return
} else {
Expand Down

0 comments on commit e11c247

Please sign in to comment.