Skip to content

Commit

Permalink
chore: execute extract-json-data and fix extract-data script to ident…
Browse files Browse the repository at this point in the history
…ify src/data.ts as script-generated, update README and minor demo fixes. (Fixes #10)
  • Loading branch information
panaC committed Nov 6, 2024
1 parent c7630f5 commit 4a84cbe
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 359 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,26 @@ It demonstrates the following features:

## QuickStart

`npm install readium-speech`
`npm install https://github.com/readium/speech`

#### node :
```
import { getVoices } from "readium-speech";
// or with cjs only :
import { getVoices } from "readium-speech/build/cjs/voices";
// or with esm mjs :
import { getVoices } from "readium-speech/build/mjs/src/voices";
const voices = await getVoices();
console.log(voices);
```
#### web :
```
import { getVoices } from "readium-speech/build/mjs/voices";
const voices = await getVoices();
// or
import { voicesSelection } from "readium-speech/build/cjs";
import { voicesSelection } from "readium-speech/build/mjs";
const voices = await voicesSelection.getVoices();
console.log(voices);
```

## API
Expand Down
148 changes: 0 additions & 148 deletions build/cjs/data.d.ts

This file was deleted.

9 changes: 0 additions & 9 deletions build/cjs/data.js

This file was deleted.

2 changes: 1 addition & 1 deletion build/cjs/voices.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TGender, TQuality, IRecommended } from "./data.js";
import { TGender, TQuality, IRecommended } from "./data.gen.js";
export interface IVoices {
label: string;
voiceURI: string;
Expand Down
14 changes: 7 additions & 7 deletions build/cjs/voices.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ exports.groupByRegions = groupByRegions;
exports.groupByKindOfVoices = groupByKindOfVoices;
exports.getLanguages = getLanguages;
exports.getVoices = getVoices;
const data_js_1 = require("./data.js");
const data_gen_js_1 = require("./data.gen.js");
// export type TOS = 'Android' | 'ChromeOS' | 'iOS' | 'iPadOS' | 'macOS' | 'Windows';
// export type TBrowser = 'ChromeDesktop' | 'Edge' | 'Firefox' | 'Safari';
const navigatorLanguages = () => { var _a; return ((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.languages) || []; };
const navigatorLang = () => ((navigator === null || navigator === void 0 ? void 0 : navigator.language) || "").split("-")[0].toLowerCase();
const normalQuality = Object.values(data_js_1.quality).map(({ normal }) => normal);
const highQuality = Object.values(data_js_1.quality).map(({ high }) => high);
const normalQuality = Object.values(data_gen_js_1.quality).map(({ normal }) => normal);
const highQuality = Object.values(data_gen_js_1.quality).map(({ high }) => high);
function compareQuality(a, b) {
const qualityToNumber = (quality) => {
switch (quality) {
Expand Down Expand Up @@ -136,12 +136,12 @@ function filterOnQuality(voices, quality) {
}
function filterOnNovelty(voices) {
return voices.filter(({ name }) => {
return !data_js_1.novelty.includes(name);
return !data_gen_js_1.novelty.includes(name);
});
}
function filterOnVeryLowQuality(voices) {
return voices.filter(({ name }) => {
return !data_js_1.veryLowQuality.find((v) => name.startsWith(v));
return !data_gen_js_1.veryLowQuality.find((v) => name.startsWith(v));
});
}
function updateVoiceInfo(recommendedVoice, voice) {
Expand All @@ -151,7 +151,7 @@ function updateVoiceInfo(recommendedVoice, voice) {
voice.recommendedRate = recommendedVoice.recommendedRate;
return voice;
}
function filterOnRecommended(voices, _recommended = data_js_1.recommended) {
function filterOnRecommended(voices, _recommended = data_gen_js_1.recommended) {
const voicesRecommended = [];
const voicesLowerQuality = [];
recommendedVoiceLoop: for (const recommendedVoice of _recommended) {
Expand Down Expand Up @@ -250,7 +250,7 @@ function orderByPreferredLanguage(preferredLanguage) {
function orderByPreferredRegion(preferredLanguage) {
preferredLanguage = Array.isArray(preferredLanguage) ? preferredLanguage :
preferredLanguage ? [preferredLanguage] : [];
const regionByDefaultArray = Object.values(data_js_1.defaultRegion);
const regionByDefaultArray = Object.values(data_gen_js_1.defaultRegion);
return [...(new Set([...preferredLanguage, ...navigatorLanguages(), ...regionByDefaultArray]))];
}
const getLangFromBCP47Array = (a) => {
Expand Down
1 change: 1 addition & 0 deletions build/mjs/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "src/index.js",
"type": "module"
}
148 changes: 0 additions & 148 deletions build/mjs/src/data.d.ts

This file was deleted.

6 changes: 0 additions & 6 deletions build/mjs/src/data.js

This file was deleted.

2 changes: 1 addition & 1 deletion build/mjs/src/voices.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TGender, TQuality, IRecommended } from "./data.js";
import { TGender, TQuality, IRecommended } from "./data.gen.js";
export interface IVoices {
label: string;
voiceURI: string;
Expand Down
Loading

0 comments on commit 4a84cbe

Please sign in to comment.