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

Update keywords #560

Merged
merged 4 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

Made in Vancouver, Canada by [Picovoice](https://picovoice.ai)

<!-- markdown-link-check-disable -->
[![Twitter URL](https://img.shields.io/twitter/url?label=%40AiPicovoice&style=social&url=https%3A%2F%2Ftwitter.com%2FAiPicovoice)](https://twitter.com/AiPicovoice)
<!-- markdown-link-check-enable -->
[![YouTube Channel Views](https://img.shields.io/youtube/channel/views/UCAdi9sTCXLosG1XeqDwLx7w?label=YouTube&style=social)](https://www.youtube.com/channel/UCAdi9sTCXLosG1XeqDwLx7w)

Picovoice is the end-to-end platform for building voice products on your terms. Unlike Alexa and Google services,
Expand Down
18 changes: 9 additions & 9 deletions resources/.test/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"parameters": [
{
"language": "ar",
"wakeword": "hummus",
"wakeword": "الحمص",
"context_name": "simple_context_ar",
"audio_file": "hummus-simple-context_ar.wav",
"inference": {
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"language": "hi",
"wakeword": "namaste",
"wakeword": "नमस्ते",
"context_name": "simple_context_hi",
"audio_file": "namaste-simple-context_hi.wav",
"inference": {
Expand All @@ -89,7 +89,7 @@
},
{
"language": "ja",
"wakeword": "ninja",
"wakeword": "忍者",
"context_name": "sumāto_shōmei",
"audio_file": "ninja-sumāto-shōmei_ja.wav",
"inference": {
Expand All @@ -101,7 +101,7 @@
},
{
"language": "ko",
"wakeword": "koppulso",
"wakeword": "코뿔소",
"context_name": "seumateu_jomyeong",
"audio_file": "koppulso-seumateu-jomyeong_ko.wav",
"inference": {
Expand All @@ -125,7 +125,7 @@
},
{
"language": "pl",
"wakeword": "porcupine_pl",
"wakeword": "jeżozwierz",
"context_name": "simple_context_pl",
"audio_file": "porcupine-simple-context_pl.wav",
"inference": {
Expand All @@ -149,7 +149,7 @@
},
{
"language": "ru",
"wakeword": "pomogite",
"wakeword": "помогите",
"context_name": "simple_context_ru",
"audio_file": "pomogite-simple-context_ru.wav",
"inference": {
Expand All @@ -161,7 +161,7 @@
},
{
"language": "sv",
"wakeword": "porcupine_sv",
"wakeword": "piggsvin",
"context_name": "simple_context_sv",
"audio_file": "porcupine-simple-context_sv.wav",
"inference": {
Expand All @@ -173,7 +173,7 @@
},
{
"language": "vn",
"wakeword": "chao_chi",
"wakeword": "chào chị",
"context_name": "simple_context_vn",
"audio_file": "chao-chi-simple-context_vn.wav",
"inference": {
Expand All @@ -185,7 +185,7 @@
},
{
"language": "zh",
"wakeword": "porcupine_zh",
"wakeword": "豪猪",
"context_name": "simple_context_zh",
"audio_file": "porcupine-simple-context_zh.wav",
"inference": {
Expand Down
2 changes: 1 addition & 1 deletion resources/porcupine
Submodule porcupine updated 402 files
72 changes: 47 additions & 25 deletions sdk/web/scripts/setup_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const { join } = require('path');
const { createHash } = require('crypto');

console.log('Copying the porcupine and rhino models...');

Expand All @@ -8,36 +9,37 @@ const fixturesDirectory = join(__dirname, '..', 'cypress', 'fixtures');

const engines = [
{
"name": "porcupine",
"dir": "keyword_files"
name: 'porcupine',
dir: 'keyword_files',
},
{
"name": "rhino",
"dir": "contexts"
}
name: 'rhino',
dir: 'contexts',
},
];

const sourceDirectory = join(
__dirname,
"..",
"..",
"..",
"resources",
);
const sourceDirectory = join(__dirname, '..', '..', '..', 'resources');

const testDataSource = join(
sourceDirectory,
'.test',
'test_data.json'
);
const testDataSource = join(sourceDirectory, '.test', 'test_data.json');

try {
fs.mkdirSync(outputDirectory, { recursive: true });
fs.copyFileSync(testDataSource, join(outputDirectory, 'test_data.json'));

fs.mkdirSync(join(fixturesDirectory, 'audio_samples'), { recursive: true });
fs.readdirSync(join(sourceDirectory, 'audio_samples')).forEach(file => {
fs.copyFileSync(join(sourceDirectory, 'audio_samples', file), join(fixturesDirectory, 'audio_samples', file));
let src = join(sourceDirectory, 'audio_samples', file);

// Bug in Cypress means we can't read utf-8 file names, so we have to hash them
let encodedAudioName = createHash('md5')
.update(file.replace('.wav', ''))
.digest('hex');
let dst = join(
fixturesDirectory,
'audio_samples',
`${encodedAudioName}.wav`
);
fs.copyFileSync(src, dst);
});

for (const engine of engines) {
Expand All @@ -52,21 +54,41 @@ try {
sourceDirectory,
engine.name,
'resources'
)
);

fs.mkdirSync(join(outputDirectory, engine.name), { recursive: true });
fs.readdirSync(paramsSourceDirectory).forEach(file => {
fs.copyFileSync(join(paramsSourceDirectory, file), join(outputDirectory, engine.name, file));
fs.copyFileSync(
join(paramsSourceDirectory, file),
join(outputDirectory, engine.name, file)
);
});

fs.mkdirSync(join(outputDirectory, engine.dir), { recursive: true });
fs.readdirSync(engineSourceDirectory).forEach(folder => {
if (folder.includes(engine.dir)) {
fs.readdirSync(join(engineSourceDirectory, folder, 'wasm')).forEach(file => {
fs.copyFileSync(
join(engineSourceDirectory, folder, 'wasm', file),
join(outputDirectory, engine.dir, file.replace("ā", "a").replace("ō", "o")));
});
fs.readdirSync(join(engineSourceDirectory, folder, 'wasm')).forEach(
file => {
let src = join(engineSourceDirectory, folder, 'wasm', file);
if (folder === engine.dir) {
let dst = join(outputDirectory, engine.dir, file);
fs.copyFileSync(src, dst);
} else {
let fileParts = file.split('_wasm');

// Bug in Cypress means we can't read utf-8 file names, so we have to hash them
let encodedFileName = createHash('md5')
.update(fileParts[0])
.digest('hex');
let dst = join(
outputDirectory,
engine.dir,
`${encodedFileName}_wasm${fileParts[1]}`
);
fs.copyFileSync(src, dst);
}
}
);
}
});
}
Expand Down
Loading