uchcharan 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uchcharan",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Make any TTS speak Indian text correctly. Normalizes ₹ amounts, lakh/crore, dates, times, phone numbers, PNR/OTP, %, units and acronyms into spoken Hindi and Marathi.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/lang/hi.js CHANGED
@@ -63,7 +63,7 @@ export default {
63
63
  '°c': 'डिग्री सेल्सियस', '°f': 'डिग्री फ़ारेनहाइट',
64
64
  },
65
65
  abbreviations: [
66
- ['Dr\\.', 'डॉक्टर'], ['Mr\\.', 'मिस्टर'], ['Mrs\\.', 'मिसेज़'], ['Ms\\.', 'मिस'], ['Smt\\.', 'श्रीमती'],
66
+ ['दि\\.', 'दिनांक'], ['Dr\\.', 'डॉक्टर'], ['Mr\\.', 'मिस्टर'], ['Mrs\\.', 'मिसेज़'], ['Ms\\.', 'मिस'], ['Smt\\.', 'श्रीमती'],
67
67
  ['Prof\\.', 'प्रोफ़ेसर'], ['etc\\.', 'वगैरह'], ['vs\\.?', 'बनाम'], ['approx\\.', 'लगभग'],
68
68
  ['Ltd\\.', 'लिमिटेड'], ['Pvt\\.', 'प्राइवेट'], ['डॉ\\.', 'डॉक्टर'],
69
69
  ],
package/src/lang/mr.js CHANGED
@@ -65,7 +65,7 @@ export default {
65
65
  '°c': 'डिग्री सेल्सिअस', '°f': 'डिग्री फॅरनहाइट',
66
66
  },
67
67
  abbreviations: [
68
- ['Dr\\.', 'डॉक्टर'], ['Mr\\.', 'मिस्टर'], ['Mrs\\.', 'मिसेस'], ['Ms\\.', 'मिस'], ['Smt\\.', 'श्रीमती'],
68
+ ['दि\\.', 'दिनांक'], ['Dr\\.', 'डॉक्टर'], ['Mr\\.', 'मिस्टर'], ['Mrs\\.', 'मिसेस'], ['Ms\\.', 'मिस'], ['Smt\\.', 'श्रीमती'],
69
69
  ['Prof\\.', 'प्रोफेसर'], ['etc\\.', 'वगैरे'], ['vs\\.?', 'विरुद्ध'], ['approx\\.', 'अंदाजे'],
70
70
  ['Ltd\\.', 'लिमिटेड'], ['Pvt\\.', 'प्रायव्हेट'], ['डॉ\\.', 'डॉक्टर'],
71
71
  ],
package/src/rules.js CHANGED
@@ -49,6 +49,13 @@ export function buildRules(L, opts) {
49
49
  re: re(String.raw`(?<![A-Za-z${DEV}])${pat}(?![A-Za-z])`),
50
50
  fn: () => rep,
51
51
  })),
52
+ {
53
+ // A number right after OTP / PIN / PNR / CVV / code is always read digit by digit,
54
+ // even when it is short (a 4-digit OTP must not become "four thousand ...").
55
+ name: 'code',
56
+ re: re(String.raw`(?<![A-Za-z${DEV}])(OTP|PIN|PNR|CVV|MPIN|UPI PIN|ओटीपी|पिन|कोड|[Cc]ode)(\s*(?:[:\-]|is|no\.?|नंबर|क्रमांक)?\s*)(\d{3,})(?![\d.,]\d|\d)`),
57
+ fn: (m, [k, sep, d]) => `${k}${sep}${digitsToWords(d, L)}`,
58
+ },
52
59
  { name: 'number-sign', re: re(String.raw`(?<![A-Za-z])(?:No\.|#)\s*(?=\d)`), fn: () => `${L.number} ` },
53
60
  {
54
61
  name: 'date',
@@ -72,14 +79,17 @@ export function buildRules(L, opts) {
72
79
  },
73
80
  {
74
81
  name: 'time',
75
- re: re(String.raw`(?<![\d:])([01]?\d|2[0-3]):([0-5]\d)(?:\s*([AaPp])\.?\s?[Mm]\.?(?![A-Za-z]))?(?![\d:])`),
76
- fn: (m, [h, min, ap]) => {
82
+ re: re(String.raw`(?<![\d:])([01]?\d|2[0-3]):([0-5]\d)(?:\s*([AaPp])\.?\s?[Mm]\.?(?![A-Za-z]))?(?![\d:])(?:\s*(बजे|वाजता|वाजले)(?![${DEV}]))?`),
83
+ // A trailing बजे / वाजता is dropped: the spoken time already ends in its own word.
84
+ fn: (m, [h, min, ap, suffix]) => {
77
85
  let h24 = Number(h);
78
86
  if (ap) {
79
87
  if (ap.toLowerCase() === 'p' && h24 < 12) h24 += 12;
80
88
  if (ap.toLowerCase() === 'a' && h24 === 12) h24 = 0;
81
89
  }
82
- return L.time(h24, Number(min), Boolean(ap) || h24 > 12 || h24 === 0, words);
90
+ const out = L.time(h24, Number(min), Boolean(ap) || h24 > 12 || h24 === 0, words);
91
+ // Marathi "10:30 वाजता" means "at 10:30": दहा वाजून तीस मिनिटांनी.
92
+ return suffix === 'वाजता' ? out.replace(/मिनिटे?$/u, 'मिनिटांनी') : out;
83
93
  },
84
94
  },
85
95
  {