ASRService.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using WingASRService.Tencent;
  2. using WingInterfaceLibrary.DTO.ASR;
  3. using WingInterfaceLibrary.Enum;
  4. using WingInterfaceLibrary.Interface;
  5. using WingInterfaceLibrary.Request.ASR;
  6. using WingServerCommon.Service;
  7. namespace WingASRService.Service
  8. {
  9. public class ASRService : JsonRpcService, IASRService
  10. {
  11. private void ThrowCustomerException(CustomerRpcCode customerRpcCodeEnum, string msg)
  12. {
  13. string customerErrorMsg = Enum.GetName(customerRpcCodeEnum) ?? string.Empty;
  14. ThrowRpcException((int)customerRpcCodeEnum, msg, customerErrorMsg);
  15. }
  16. public async Task<ASRResultDTO> CommitASRInfoAsync(CommitASRInfoRequest request)
  17. {
  18. var result = ASRApi.CallASRApi(request.Url, request.FileType);
  19. if (!result.isSuccess)
  20. {
  21. ThrowCustomerException(CustomerRpcCode.ASRError, result.message);
  22. }
  23. return await Task.FromResult(new ASRResultDTO
  24. {
  25. IsComplete = result.isSuccess,
  26. Content = result.message,
  27. });
  28. }
  29. }
  30. }