index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // 语音转文字 获取token
  2. import config from '@/config'
  3. const baseUrl = config.baseUrl
  4. export function turnWordLogin(data) {
  5. console.log(7)
  6. return new Promise((resolve, reject) => {
  7. // var url='https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=Va5yQRHlA4Fq5eR3LT0vuXV4&client_secret=0rDSjzQ20XUj5itV6WRtznPQSzr5pVw2&'
  8. uni.request({
  9. url: 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=MuVtMTc6EHaLbrr38WEhqjml&client_secret=rPGCiA3L41VwuTCBHkwkmcOt0IPTsi8z', //仅为示例,并非真实接口地址。
  10. data:data,
  11. method: 'POST',
  12. header: {'content-type': 'application/json;charset=utf-8' },
  13. success: (res) => {
  14. resolve(res.data)
  15. },
  16. fail:(erroe)=>{
  17. reject(error)
  18. }
  19. });
  20. })
  21. }
  22. export function uploadOffline(data){
  23. return new Promise((resolve, reject) => {
  24. uni.request({
  25. url: ' http://vop.baidu.com/server_api', //仅为示例,并非真实接口地址。
  26. data:data,
  27. header: {
  28. 'content-type': 'Content-Type: audio/pcm;rate=16000',
  29. },
  30. method: 'POST',
  31. success: (res) => {
  32. console.log(res,88)
  33. resolve(res.data)
  34. },
  35. fail:(erroe)=>{
  36. reject(error)
  37. }
  38. });
  39. })
  40. }