@kne/fastify-aliyun 1.0.0 → 1.0.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.
@@ -20,7 +20,8 @@ module.exports = fp(async (fastify, options) => {
20
20
  type: 'object',
21
21
  required: ['text'],
22
22
  properties: {
23
- text: { type: 'string' }
23
+ text: { type: 'string' },
24
+ audioName: { type: 'string' }
24
25
  }
25
26
  }
26
27
  }
package/libs/services.js CHANGED
@@ -19,7 +19,7 @@ module.exports = fp(async (fastify, options) => {
19
19
  return { token: Token.Id };
20
20
  };
21
21
 
22
- const tts = async ({ text }) => {
22
+ const tts = async ({ text, audioName }) => {
23
23
  const { token } = await getToken();
24
24
  const response = await fetch(options.nls.tts.endpoint, {
25
25
  method: 'POST',
@@ -34,14 +34,6 @@ module.exports = fp(async (fastify, options) => {
34
34
  })
35
35
  });
36
36
 
37
- console.log(
38
- JSON.stringify({
39
- appkey: options.nls.appkey,
40
- text: text,
41
- token: token,
42
- format: 'wav'
43
- })
44
- );
45
37
  const buffer = await response.buffer();
46
38
  const type = await fileType.fromBuffer(buffer);
47
39
  if (!type) {
@@ -56,7 +48,7 @@ module.exports = fp(async (fastify, options) => {
56
48
  throw new Error(errorMsg);
57
49
  }
58
50
  return await fastify.fileManager.services.fileRecord.uploadToFileSystem({
59
- file: { toBuffer: () => buffer, filename: `response.${type.ext}`, mimetype: type.mime }
51
+ file: { toBuffer: () => buffer, filename: `${audioName || 'audio'}.${type.ext}`, mimetype: type.mime }
60
52
  });
61
53
  };
62
54
  fastify.aliyun.services = { getToken, tts };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-aliyun",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "对接阿里云服务",
5
5
  "main": "index.js",
6
6
  "scripts": {