koishi-plugin-chatsound 0.0.3 → 1.0.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.
package/lib/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare module 'koishi' {
7
7
  }
8
8
  export declare const name = "chatsound";
9
9
  export declare const inject: {
10
- required: string[];
10
+ optional: string[];
11
11
  };
12
12
  export interface Config {
13
13
  soundPath: string[];
package/lib/index.js CHANGED
@@ -30,14 +30,12 @@ var import_koishi = require("koishi");
30
30
  var import_promises = require("fs/promises");
31
31
  var import_path = require("path");
32
32
  var import_child_process = require("child_process");
33
- var import_util = require("util");
34
- var execAsync = (0, import_util.promisify)(import_child_process.exec);
35
33
  var name = "chatsound";
36
34
  var inject = {
37
- required: ["silk"]
35
+ optional: ["silk"]
38
36
  };
39
37
  var Config = import_koishi.Schema.object({
40
- soundPath: import_koishi.Schema.array(import_koishi.Schema.string()).description("用于搜索的音频路径"),
38
+ soundPath: import_koishi.Schema.array(import_koishi.Schema.string()).description("用于搜索音频的*绝对*路径,支持搜索mp3 wav ogg flac m4a aac格式"),
41
39
  defaultPitch: import_koishi.Schema.number().default(100).description("默认的语音音调(百分比)"),
42
40
  minPitch: import_koishi.Schema.number().default(80).min(0).description("最小Pitch,不小于0"),
43
41
  maxPitch: import_koishi.Schema.number().default(200).description("最大Pitch"),
@@ -69,8 +67,6 @@ async function runFFmpeg(commandArgs) {
69
67
  const ffmpeg = (0, import_child_process.spawn)("ffmpeg", commandArgs);
70
68
  const chunks = [];
71
69
  ffmpeg.stdout.on("data", (chunk) => chunks.push(chunk));
72
- ffmpeg.stderr.on("data", (chunk) => {
73
- });
74
70
  ffmpeg.on("close", (code) => {
75
71
  if (code === 0) {
76
72
  resolve(Buffer.concat(chunks));
@@ -136,8 +132,12 @@ function apply(ctx, config) {
136
132
  try {
137
133
  const { data, mimeType } = await applyPitch(audioPath, actualPitch, config.audioType);
138
134
  if (config.audioType === "silk") {
139
- const silkResult = await ctx.silk.encode(data, 24e3);
140
- await session.send(import_koishi.h.audio(silkResult.data, "audio/silk"));
135
+ if (ctx.silk) {
136
+ const silkResult = await ctx.silk.encode(data, 24e3);
137
+ await session.send(import_koishi.h.audio(silkResult.data, "audio/silk"));
138
+ } else {
139
+ return "没有安装必要的SILK插件";
140
+ }
141
141
  } else {
142
142
  await session.send(import_koishi.h.audio(data, mimeType));
143
143
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "Dr.Abc <me@drabc.net>"
6
6
  ],
7
- "version": "0.0.3",
7
+ "version": "1.0.0",
8
8
  "homepage": "https://github.com/DrAbcOfficial/koishi-plugin-chatsound",
9
9
  "repository": {
10
10
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "zh": "发送预定的噪音,可以变调,依赖ffmpeg"
34
34
  },
35
35
  "service":{
36
- "required": ["silk"]
36
+ "optional": ["silk"]
37
37
  },
38
38
  "preview": true
39
39
  }