henkan 0.8.0 → 0.9.0

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.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs.js +8 -25
  3. package/dist/index.cjs.js.map +3 -3
  4. package/dist/index.mjs +10 -25
  5. package/dist/index.mjs.map +2 -2
  6. package/dist/types/utils.d.ts +8 -11
  7. package/dist/types/utils.d.ts.map +1 -1
  8. package/docs/api/functions/capitalizeString.md +1 -1
  9. package/docs/api/functions/convertJMdict.md +1 -1
  10. package/docs/api/functions/convertKanjiDic.md +1 -1
  11. package/docs/api/functions/convertKradFile.md +1 -1
  12. package/docs/api/functions/convertRadkFile.md +1 -1
  13. package/docs/api/functions/convertTanakaCorpus.md +1 -1
  14. package/docs/api/functions/generateAnkiNote.md +1 -1
  15. package/docs/api/functions/generateAnkiNotesFile.md +1 -1
  16. package/docs/api/functions/getKanji.md +1 -1
  17. package/docs/api/functions/getKanjiExtended.md +1 -1
  18. package/docs/api/functions/getWord.md +1 -1
  19. package/docs/api/functions/isStringArray.md +1 -1
  20. package/docs/api/functions/isValidArray.md +1 -1
  21. package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
  22. package/docs/api/functions/shuffleArray.md +1 -1
  23. package/docs/api/functions/synthesizeSpeech.md +13 -25
  24. package/docs/api/interfaces/DictKanji.md +5 -5
  25. package/docs/api/interfaces/DictKanjiForm.md +4 -4
  26. package/docs/api/interfaces/DictKanjiMisc.md +5 -5
  27. package/docs/api/interfaces/DictKanjiReading.md +3 -3
  28. package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
  29. package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
  30. package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
  31. package/docs/api/interfaces/DictMeaning.md +11 -11
  32. package/docs/api/interfaces/DictRadical.md +4 -4
  33. package/docs/api/interfaces/DictReading.md +5 -5
  34. package/docs/api/interfaces/DictWord.md +8 -8
  35. package/docs/api/interfaces/ExamplePart.md +7 -7
  36. package/docs/api/interfaces/GlossSpecificNumber.md +3 -3
  37. package/docs/api/interfaces/Grammar.md +15 -15
  38. package/docs/api/interfaces/GrammarMeaning.md +3 -3
  39. package/docs/api/interfaces/Kana.md +11 -11
  40. package/docs/api/interfaces/Kanji.md +22 -22
  41. package/docs/api/interfaces/KanjiComponent.md +3 -3
  42. package/docs/api/interfaces/KanjiForm.md +4 -4
  43. package/docs/api/interfaces/NoteAndTag.md +3 -3
  44. package/docs/api/interfaces/Phrase.md +5 -5
  45. package/docs/api/interfaces/Radical.md +16 -16
  46. package/docs/api/interfaces/Reading.md +5 -5
  47. package/docs/api/interfaces/ResultEntry.md +7 -7
  48. package/docs/api/interfaces/TanakaExample.md +7 -7
  49. package/docs/api/interfaces/Translation.md +3 -3
  50. package/docs/api/interfaces/UsefulRegExps.md +8 -8
  51. package/docs/api/interfaces/Word.md +14 -14
  52. package/docs/api/type-aliases/Dict.md +1 -1
  53. package/docs/api/type-aliases/DictName.md +1 -1
  54. package/docs/api/type-aliases/EntryType.md +1 -1
  55. package/docs/api/type-aliases/JLPT.md +1 -1
  56. package/docs/api/type-aliases/Result.md +1 -1
  57. package/package.json +2 -2
package/README.md CHANGED
@@ -36,7 +36,7 @@ pnpm add henkan
36
36
  - JMdict, KANJIDIC, Tanaka Corpus, RADK and KRAD conversion
37
37
  - User-friendly schemas for dictionary entries
38
38
  - Anki note generation
39
- - Other useful tools (TTSFree.com audio generation, Japanese RegExps, array checking etc.)
39
+ - Other useful tools (Amazon Polly audio generation, Japanese RegExps, array checking etc.)
40
40
 
41
41
  ---
42
42
 
package/dist/index.cjs.js CHANGED
@@ -1134,7 +1134,7 @@ var noteMap = /* @__PURE__ */ new Map([
1134
1134
  var import_libxmljs2 = __toESM(require("libxmljs2"));
1135
1135
  var import_xml2js = __toESM(require("xml2js"));
1136
1136
  var import_iconv_lite = __toESM(require("iconv-lite"));
1137
- var import_node_fetch = __toESM(require("node-fetch"));
1137
+ var import_client_polly = require("@aws-sdk/client-polly");
1138
1138
  var Kuroshiro = require("kuroshiro");
1139
1139
  var KuromojiAnalyzer = require("kuroshiro-analyzer-kuromoji");
1140
1140
  function capitalizeString(value) {
@@ -2002,34 +2002,17 @@ function getKanjiExtended(kanjiChar, info, dict, useJpdbWords, jmDict, svgList,
2002
2002
  throw err;
2003
2003
  }
2004
2004
  }
2005
- async function synthesizeSpeech(textOrSSML, apiKey, options) {
2005
+ async function synthesizeSpeech(client, input, options) {
2006
2006
  return await new Promise(
2007
2007
  async (resolve, reject) => {
2008
2008
  try {
2009
- const res = await (0, import_node_fetch.default)("https://ttsfree.com/api/v1/tts", {
2010
- method: "POST",
2011
- body: JSON.stringify({
2012
- text: textOrSSML,
2013
- ...options
2014
- }),
2015
- headers: {
2016
- "Content-Type": "application/json",
2017
- apikey: apiKey
2018
- }
2009
+ const command = new import_client_polly.SynthesizeSpeechCommand({
2010
+ Text: input,
2011
+ ...options
2019
2012
  });
2020
- if (!res.ok)
2021
- throw new Error(
2022
- `TTS request failed:
2023
- ${res.status}: ${res.statusText}`
2024
- );
2025
- const data = await res.json();
2026
- if (data.status !== "success" || data.mess !== "success" || data.audioData.length === 0)
2027
- throw new Error("Invalid TTS response data");
2028
- const mp3Buffer = Buffer.from(
2029
- data.audioData,
2030
- "base64"
2031
- );
2032
- resolve(mp3Buffer);
2013
+ const response = await client.send(command);
2014
+ const stream = response.AudioStream ? Buffer.from(await response.AudioStream.transformToByteArray()) : null;
2015
+ resolve(stream);
2033
2016
  } catch (err) {
2034
2017
  reject(err);
2035
2018
  }