speechready 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/verbalize/en.js +2 -0
- package/dist/verbalize/tr.js +11 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/verbalize/en.js
CHANGED
|
@@ -149,6 +149,7 @@ function fraction(m) {
|
|
|
149
149
|
return `${cardinal(num)} ${num === 1 ? one : many}`;
|
|
150
150
|
}
|
|
151
151
|
const YEAR_LIKE = re(String.raw `(19|20)\d\d`);
|
|
152
|
+
const minus = (m) => `${m[1]} minus ${m[2]}`;
|
|
152
153
|
function range(m) {
|
|
153
154
|
const a = m[1];
|
|
154
155
|
const b = m[2];
|
|
@@ -209,6 +210,7 @@ export const RULES = [
|
|
|
209
210
|
rule("verbalize.percent", re(String.raw `(?<![${W}.])(\d+(?:\.\d+)?)\s?%|%\s?(\d+(?:\.\d+)?)`), (m) => `${group(m, 1) ?? group(m, 2)} percent`, "percent sign read as a word"),
|
|
210
211
|
rule("verbalize.unit", re(String.raw `(?<![${W}.])(\d+(?:\.\d+)?)\s?(${UNIT_ALTERNATION})(?![${W}/])`), unit, "unit abbreviation read as a word"),
|
|
211
212
|
rule("verbalize.fraction", re(String.raw `(?<![\d/])([1-9])/([2-9]|10)(?![\d/])`), fraction, "fraction read as words"),
|
|
213
|
+
rule("verbalize.minus", re(String.raw `(?<![${W}.,\-/:])(\d+(?:\.\d+)?) - (\d+(?:\.\d+)?)(?=\s*=)`), minus, "spaced minus in an equation read as 'minus'"),
|
|
212
214
|
rule("verbalize.range", re(String.raw `(?<![${W}.,\-/:])(\d+(?:\.\d+)?)\s?[-–]\s?(\d+(?:\.\d+)?)(?![${W}\-/:]|[.,]\d)`), range, "number range read with 'to'"),
|
|
213
215
|
rule("verbalize.year", re(String.raw `${B}(in|In|since|Since|by|from|until|till|before|after|during|circa|year|est\.|©)\s+(1[1-9]\d\d|20\d\d)${B}(?![${W}.,]?\d)`), yearInContext, "year read as a year"),
|
|
214
216
|
rule("verbalize.decade", re(String.raw `${B}(1[1-9]\d0|20\d0)s${B}`), decade, "decade read as a year"),
|
package/dist/verbalize/tr.js
CHANGED
|
@@ -66,7 +66,13 @@ function timeWords(hh, mm) {
|
|
|
66
66
|
return `${hour} sıfır sıfır`;
|
|
67
67
|
return `${hour} ${mm[0] !== "0" ? cardinal(minute) : "sıfır " + cardinal(minute)}`;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
function time(m) {
|
|
70
|
+
const suffix = group(m, 3) ?? "";
|
|
71
|
+
if (suffix && parseInt(m[2], 10) === 0)
|
|
72
|
+
return attach(cardinal(parseInt(m[1], 10)), suffix); // 14.00'teki -> on dörtteki
|
|
73
|
+
return attach(timeWords(m[1], m[2]), suffix);
|
|
74
|
+
}
|
|
75
|
+
const minus = (m) => `${m[1]} eksi ${m[2]}`;
|
|
70
76
|
const timeRange = (m) => `${timeWords(m[1], m[2])} ile ${timeWords(m[3], m[4])}`;
|
|
71
77
|
const CURRENCY = {
|
|
72
78
|
"₺": ["lira", "kuruş"], TL: ["lira", "kuruş"], TRY: ["lira", "kuruş"],
|
|
@@ -181,12 +187,15 @@ export const RULES = [
|
|
|
181
187
|
rule("verbalize.abbreviation", re(String.raw `(?<![${W}.])(${ABBR_ALTERNATION})\.(?![${LOWER}${UPPER}])`), abbreviation, "abbreviation read in full"),
|
|
182
188
|
rule("verbalize.date.dmy", re(String.raw `${B}(\d{1,2})[./](\d{1,2})[./](\d{4}|\d{2})${B}${SUFFIX}`), dateDmy, "date read as day, month name, year"),
|
|
183
189
|
rule("verbalize.date.iso", re(String.raw `${B}(\d{4})-(\d{2})-(\d{2})${B}${SUFFIX}`), dateIso, "ISO date read as day, month name, year"),
|
|
190
|
+
rule("verbalize.time.range", re(String.raw `${B}([01]?\d|2[0-3])[.:]([0-5]\d)\s?[-–]\s?([01]?\d|2[0-3])[.:]([0-5]\d)${B}(?![.,]\d)`), timeRange, "time range read with 'ile'"),
|
|
184
191
|
rule("verbalize.phone", re(String.raw `(?<![${W}.])((?:\+?\d{1,3}${SEP})?(?:\(\d{2,4}\)[ \-]?|\d{2,4}${SEP})(?:\d{2,4}${SEP}){1,4}\d{2,4})${SUFFIX}(?![${W}\-]|[.,]\d)`), digitGroups, "digit groups read digit by digit with a pause between groups"),
|
|
185
192
|
rule("verbalize.number_sign", re(String.raw `#(?=\d)`), () => "numara ", "number sign read as a word"),
|
|
186
193
|
rule("verbalize.acronym.foreign", re(String.raw `(?<![${W}'’.])[bcdfghjklmnpqrstvwxyz]{2,5}(?![${W}'’])`), foreignAcronym, "lowercase foreign acronym read with English letter names"),
|
|
187
194
|
rule("verbalize.digits.long", re(String.raw `(?<![${W}.,])\d{7,}(?![${W}]|[.,]\d)`), (m) => digits(m[0]), "long digit string read digit by digit"),
|
|
188
|
-
rule("verbalize.time.range", re(String.raw `${B}([01]?\d|2[0-3]):([0-5]\d)\s?[-–]\s?([01]?\d|2[0-3]):([0-5]\d)${B}`), timeRange, "time range read with 'ile'"),
|
|
189
195
|
rule("verbalize.time", re(String.raw `${B}([01]?\d|2[0-3]):([0-5]\d)${B}(?!:)${SUFFIX}`), time, "clock time read as hours and minutes"),
|
|
196
|
+
// Turkish also writes times with a dot (saat 14.00); taken as a time only after "saat" or with a suffix, since 22.22 may be a decimal
|
|
197
|
+
rule("verbalize.time.dotted", re(String.raw `(?:(?<=[Ss]aat )|(?=[0-2]?\d\.[0-5]\d${APOS}))${B}([01]?\d|2[0-3])\.([0-5]\d)${B}(?![.,]\d)${SUFFIX}`), time, "dotted clock time read as hours and minutes"),
|
|
198
|
+
rule("verbalize.minus", re(String.raw `(?<![${W}.,\-/:])(\d+(?:,\d+)?) - (\d+(?:,\d+)?)(?=\s*=)`), minus, "spaced minus in an equation read as 'eksi'"),
|
|
190
199
|
rule("verbalize.currency.postfix", re(String.raw `(?<![${W}.,])(\d+(?:,\d+)?)\s?(bin|milyon|milyar)?\s?([₺$€£])${SUFFIX}(?![${W}])`), currencyPostfix, "currency symbol after the amount read as words"),
|
|
191
200
|
rule("verbalize.currency", re(String.raw `([₺$€£])\s?(\d{1,3}(?:\.\d{3})*|\d+)(?:,(\d{1,2}))?${SUFFIX}(?![${W}]|[.,]\d)`), currencyPrefix, "currency amount read as words"),
|
|
192
201
|
rule("verbalize.currency.code", re(String.raw `(?<![${W}.,])(\d{1,3}(?:\.\d{3})*|\d+)(?:,(\d{1,2}))?\s?(TL|TRY|USD|EUR|GBP)${B}${SUFFIX}`), currencySuffix, "currency code read as words"),
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.3.
|
|
1
|
+
export declare const version = "0.3.1";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/build-profiles.mjs from package.json. Do not edit.
|
|
2
|
-
export const version = "0.3.
|
|
2
|
+
export const version = "0.3.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speechready",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Prepare text for text-to-speech: clean LLM output, verbalize ambiguous tokens, compile pauses to each provider's syntax, chunk under model limits.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|