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/dist/index.mjs CHANGED
@@ -1082,7 +1082,9 @@ var noteMap = /* @__PURE__ */ new Map([
1082
1082
  import libxml from "libxmljs2";
1083
1083
  import xml from "xml2js";
1084
1084
  import iconv from "iconv-lite";
1085
- import fetch from "node-fetch";
1085
+ import {
1086
+ SynthesizeSpeechCommand
1087
+ } from "@aws-sdk/client-polly";
1086
1088
  var Kuroshiro = __require("kuroshiro");
1087
1089
  var KuromojiAnalyzer = __require("kuroshiro-analyzer-kuromoji");
1088
1090
  function capitalizeString(value) {
@@ -1945,34 +1947,17 @@ function getKanjiExtended(kanjiChar, info, dict, useJpdbWords, jmDict, svgList,
1945
1947
  throw err;
1946
1948
  }
1947
1949
  }
1948
- async function synthesizeSpeech(textOrSSML, apiKey, options) {
1950
+ async function synthesizeSpeech(client, input, options) {
1949
1951
  return await new Promise(
1950
1952
  async (resolve, reject) => {
1951
1953
  try {
1952
- const res = await fetch("https://ttsfree.com/api/v1/tts", {
1953
- method: "POST",
1954
- body: JSON.stringify({
1955
- text: textOrSSML,
1956
- ...options
1957
- }),
1958
- headers: {
1959
- "Content-Type": "application/json",
1960
- apikey: apiKey
1961
- }
1954
+ const command = new SynthesizeSpeechCommand({
1955
+ Text: input,
1956
+ ...options
1962
1957
  });
1963
- if (!res.ok)
1964
- throw new Error(
1965
- `TTS request failed:
1966
- ${res.status}: ${res.statusText}`
1967
- );
1968
- const data = await res.json();
1969
- if (data.status !== "success" || data.mess !== "success" || data.audioData.length === 0)
1970
- throw new Error("Invalid TTS response data");
1971
- const mp3Buffer = Buffer.from(
1972
- data.audioData,
1973
- "base64"
1974
- );
1975
- resolve(mp3Buffer);
1958
+ const response = await client.send(command);
1959
+ const stream = response.AudioStream ? Buffer.from(await response.AudioStream.transformToByteArray()) : null;
1960
+ resolve(stream);
1976
1961
  } catch (err) {
1977
1962
  reject(err);
1978
1963
  }