Skip to content
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

WIP: Voice commands using phrase embeddings #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

choombaa
Copy link
Collaborator

@choombaa choombaa commented Jul 6, 2023

Run npm run embed to generate embeddings based on the commands.json file.

Every transcription embedded and compared against
a set of phrases. If there is a match above a threshold, the command is triggered.

Run `npm run embed` to generate embeddings based on
the commands.json file.

Every transcription embedded and compared against
a set of phrases. If there is a match above a threshold, the
command is triggered.
@choombaa
Copy link
Collaborator Author

choombaa commented Jul 6, 2023

This is a WIP

@ghost ghost changed the title Voice commands using phrase embeddings WIP: Voice commands using phrase embeddings Jul 6, 2023
@ghost ghost added the DO NOT MERGE label Jul 6, 2023
Comment on lines +47 to +63
if ((!A.length) || (!B.length) || (A.length !== B.length)) {
throw new Error('Invalid vectors');
}
let dotProduct = 0;
let magA = 0;
let magB = 0;

for (let i=0; i<A.length; i++) {
dotProduct += A[i] * B[i];
magA += A[i] * A[i];
magB += B[i] * B[i];
}
magA = Math.sqrt(magA);
magB = Math.sqrt(magB);

return dotProduct / (magA * magB);
Copy link
Owner

Choose a reason for hiding this comment

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

oh what? cosine similarity is just dot product operation? :^)

@jmanhype
Copy link

jmanhype commented Jul 8, 2023

Can you hook this up to https://github.com/tmc/righthand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants