@picovoice/orca-node-demo
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@picovoice/orca-node-demo", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Picovoice Orca Node.js file-based and streaming demos", | ||
@@ -24,4 +24,4 @@ "scripts": { | ||
"dependencies": { | ||
"@picovoice/orca-node": "=1.0.0", | ||
"@picovoice/pvspeaker-node": "^1.0.1", | ||
"@picovoice/orca-node": "=1.0.1", | ||
"@picovoice/pvspeaker-node": "^1.0.2", | ||
"commander": "^6.1.0", | ||
@@ -28,0 +28,0 @@ "prettier": "^2.6.2", |
@@ -12,3 +12,3 @@ # Orca Streaming Text-to-Speech Demos | ||
- Cross-Platform: | ||
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64) | ||
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64) | ||
- Android and iOS | ||
@@ -21,3 +21,3 @@ - Chrome, Safari, Firefox, and Edge | ||
- Node.js 16+ | ||
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5). | ||
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5). | ||
@@ -24,0 +24,0 @@ ## Installation |
@@ -68,2 +68,27 @@ #! /usr/bin/env node | ||
program.parse(process.argv); | ||
function splitText(text) { | ||
// TODO: Remove once tiktoken supports windows-arm64 | ||
if (os.platform() === 'win32' && os.arch() === 'arm64') { | ||
const ALPHA_NUMERIC = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ' | ||
const PUNCTUATION = '!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~ ' | ||
const tokensRaw = [ text[0] ] | ||
for (let i = 1; i < text.length; i++) { | ||
let ch = text[i]; | ||
let token = tokensRaw[tokensRaw.length - 1]; | ||
if ((ALPHA_NUMERIC.includes(ch) && !ALPHA_NUMERIC.includes(token[token.length - 1])) || PUNCTUATION.includes(ch)) { | ||
tokensRaw.push(ch); | ||
} else { | ||
tokensRaw[tokensRaw.length - 1] += ch; | ||
} | ||
} | ||
return tokensRaw; | ||
} else { | ||
const textDecoder = new TextDecoder(); | ||
const encoder = tiktoken.encoding_for_model('gpt-4'); | ||
const tokensRaw = Array.from(encoder.encode(text), e => textDecoder.decode(encoder.decode([e]))); | ||
encoder.free(); | ||
return tokensRaw; | ||
} | ||
} | ||
@@ -78,12 +103,8 @@ function tokenizeText(text) { | ||
const encoder = tiktoken.encoding_for_model('gpt-4'); | ||
const tokensRaw = Array.from(encoder.encode(text), e => encoder.decode([e])); | ||
encoder.free(); | ||
const tokensRaw = splitText(text); | ||
let customPron = ''; | ||
const tokensWithCustomPronunciations = []; | ||
const textDecoder = new TextDecoder(); | ||
tokensRaw.forEach((t, i) => { | ||
const token = textDecoder.decode(t); | ||
tokensRaw.forEach((token, i) => { | ||
let inCustomPron = false; | ||
@@ -90,0 +111,0 @@ customPronunciations.forEach(pron => { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15740
350
2