get-voice-point.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2020 Tencent Cloud.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. 'use strict';
  17. const { request } = require('./utils');
  18. /**
  19. * 获取参数
  20. * @param {object} param - 待包装对象
  21. * @return {object} 包装参数对象
  22. */
  23. function getParams(param) {
  24. const paramsData = {
  25. SeqId: param.seqId,
  26. IsEnd: param.isEnd,
  27. VoiceFileType: 3,
  28. VoiceEncodeType: 1,
  29. UserVoiceData: param.voiceData,
  30. SessionId: param.sessionId,
  31. RefText: param.refText,
  32. WorkMode: param.workMode,
  33. EvalMode: param.evalMode,
  34. ScoreCoeff: param.scoreCoeff
  35. };
  36. // 非必填参数
  37. param.hasOwnProperty('soeAppId') && (paramsData.SoeAppId = param.soeAppId);
  38. param.hasOwnProperty('storageMode') && (paramsData.StorageMode = param.storageMode);
  39. param.hasOwnProperty('sentenceInfoEnabled') && (paramsData.SentenceInfoEnabled = param.sentenceInfoEnabled);
  40. param.hasOwnProperty('serverType') && (paramsData.ServerType = param.serverType);
  41. param.hasOwnProperty('textMode') && (paramsData.TextMode = param.textMode);
  42. return paramsData;
  43. }
  44. /**
  45. * 获取口语评测信息
  46. * 更多信息请访问 https://cloud.tencent.com/document/api/884/32605
  47. * @param {object} params - 参数包装对象
  48. * @param {object} params.param - 口语评测相关参数
  49. * @return {Promise<object>} 评测信息
  50. */
  51. async function getVoicePoint({ param }) {
  52. const paramsData = getParams(param);
  53. // 调用腾讯云发音数据传输接口附带初始化过程接口
  54. const evaluateInfo = await request('TransmitOralProcessWithInit', paramsData);
  55. return evaluateInfo;
  56. }
  57. module.exports = getVoicePoint;