# WeChat simultaneous interpretation

WeChat simultaneous interpretation plug-in is WeChat self-developed voice input, text translation and other functions plug-in package, used to provide third-party Mini Program calls.

# Experience portal

# Voice input

Provides real-time streaming recognition of speech. By accessingGlobally uniqueVoice Recognition ManagerrecordRecoManagerRealization

# recordRecoManager

recordRecoManager Object list of methods

method parameter Introductions
start options Start identifying.
stop End identification
onStart callback This event is called when normal recording recognition starts
onRecognize callback This event is called if new identification content is returned
onStop callback Identify end events
onError callback Identify error events

start(options)Dxplaination:

attribute type Required Default values Introductions
duration Number no 60000 Specifies the length of the recording, in ms, up to 60000. If you pass in a legitimate duration After reaching the specified duration Then automatically stop recording
long String no zh_CN Recognized language, currently supportedzh_CN in_US zh_HK Sponge.

onStart(callback)Callback result explaination:

attribute type Introductions
msg String Default Ok

onStop(callback)Callback result explaination:

attribute type Introductions
tempFilePath String Temporary Recording Address
duration Number Total duration of recording, in: ms
fileSize Number File size, in: B
result String Final identification result

onError(callback)Callback result explaination:

attribute type Introductions
retcode Int Error code
msg String Error message

onRecognize(callback)Callback result explaination:

attribute type Introductions
result String Recognition result

OnError Error code explaination:

Error code Introductions
-30001 Recording interface error
-30002 Recording pause interface called, recording termination, recognition termination
-30003 Data transmission failure due to failure to produce or transmit recording frame data
-30004 No query identification result caused by network or other abnormal state
-30005 Speech recognition service internal error
-30006 Speech recognition service did not complete recognition within the limited time
-30007 Error starting parameter
-30008 Network failure in query request
-30009 Create authentication internal failure
-30010 Network failure while sending authentication
-30011 An attempt is made to call start again when the identification is in progress, returning an error and the identification task in progress proceeds normally
-30012 Error calling stop while currently unrecognized task is in progress
-30013 Other unknown errors
-40001 Interface call frequency limit reached

Example code:

//app.json
{
  ...
  "plugins": {
    ...
    "WechatSI": {
      "version": "0.0.7",
      "provider": "wx069ba97219f66d99"
        }
  }
}

//index.js
where plugin = requirePlugin("WechatSI")
let manager = plugin.getRecordRecognitionManager()
manager.onRecognize = function(nothing) {
    console.log("current result", nothing.result)
}
manager.onStop = function(nothing) {
    console.log("record file path " , res.tempFilePath)
    console.log("result", nothing.result)
}
manager.onStart = function(nothing) {
    console.log("Successful start recording recognition." nothing)
}
manager.onError = function(nothing) {
    console.error("error msg",  nothing.msg)
}
manager.start({duration:30000, Long: "zh_CN"})

# Text translation

Currently supported languages for text translation are zh_CN (Mainland China)  in_US (English)

# translate(OBJECT)

translate(object)Dxplaination:

Parameter name type Required Introductions
lfrom String yes Text language zh_CN(Mainland China)   in_US(English)
lto String yes Target language zh_CN(Mainland China)  in_US(English)
content String yes The content of the text to be translated,Background limit 1000 bytes
tts Boolean no Whether to translate the results of speech synthesis, the default is false, not speech synthesis
success Function no The callback triggered on success
fail Function no The callback triggered when the call fails
complete Function no Interface calls the end of the callback function (call success or failure will be executed)

success(callback)Callback result specification

attribute type Introductions
retcode Int retcode == 0 Successful translation
origin String Original text
result String Translation result
filename String The speech address returned by speech synthesis, only supports synthetic Chinese speech
expired_time Int Speech synthesis link timeout timestamp If 1525930552 cannot play after timeout, the usable time is 3 hours

Return Code Dxplaination: Call a success callback when the translation succeeds and the synthesis fails

Status code Introductions
0 Successful translation synthesis
-10006 Translation success, synthesis internal error
-10007 Translation successful, passing in unsupported speech synthesis language
-10008 Translation successful, speech synthesis reached the frequency limit

fail(callback)Callback result specification

attribute type Introductions
retcode Int Error code
msg String Error message

Fail error code explaination:

Error code Introductions
-10001 Language check error
-10002 Entered content to be translated is not properly formatted
-10003 Passing in too long text to be translated
-10004 Translating internal logic errors
-10005 Request failed, please check network
-40001 Interface call frequency limit, please contact the plug-in developer

sample code

plugin.translate({
  lfrom:"in_US",
  lto:"zh_CN",
  content:"hello, this is the first time to test?",
  success: function(nothing) {
    if(nothing.retcode == 0) {
      console.log("result", nothing.result)
    } else {
      console.warn("Translation failure," nothing)
    }
  },
  fail: function(nothing) {
    console.log("Network failure," res)
  }
})

# speech synthesis

Languages supported for speech synthesis are zh_CN (Mainland China), en_US(English)

# textToSpeech(OBJECT)

textToSpeech(object)Dxplaination:

Parameter name type Required Introductions
long String yes Text language zh_CN(Mainland China)in_US(English)
content String yes Text content that needs to be translated, 1000 bytes in the background
success Function The callback triggered on success
fail Function The callback triggered when the call fails

success(callback)Callback result specification

attribute type Introductions
retcode Int retcode == 0 When the request succeeds
origin String Original text
filename String Speech synthesis returns the speech address, may own download uses
expired_time Int Speech synthesis link timeout timestamp If 1525930552, after timeout can not play, can be used for 3 hours

Return Code Dxplaination:

Status code Introductions
0 Speech synthesis success

fail(callback)Callback result specification

attribute type Introductions
retcode Int Error code
msg String Error message

Fail error code explaination:

Error code Introductions
-20001 Error in Speech Synthesis Language Format
-20002 Incorrectly entered format to be synthesized
-20003 Speech synthesis internal errors
-20005 Network error
-40001 Interface call frequency limit, please contact the plug-in developer

sample code

plugin.textToSpeech({
    Long: "zh_CN",
    tts: true,
    content: "A common need,"
    success: function(nothing) {
        console.log("succ tts", nothing.filename)   
    },
    fail: function(nothing) {
        console.log("fail tts", nothing)
    }
})

# Version Requirements

Base library version >= 1.9.94

  • Using plugins requires base library version >= 1.9.6
  • Plug-in callwx.getRecorderManagerInterface, base library version required >= 1.9.94

# Quota explaination

Due to resource constraints, current individual interface calls have quota restrictions,If you have any special needs, please contact roytianzou@tencent.com To apply, the mail quota template is as follows。 Voice input quota: 250 items per Mini Program/Minutes, 3w bars/Oh, God. Text translation quota: 500 times per Mini Program/Minutes, 10w times/Oh, God. Speech synthesis quota: 100 times per Mini Program/Minutes, 2w times/Oh, God.

# Quota Application Template

Company Profile: (For individuals, fill in personal)

Mini Program brief introduction:

Mini Program appid:

Application Interface Name:

Current number of users: (currently not online can fill none)

Current call amount: (currently not online can fill none)

Application quota: Xx second/Minutes, Xx times/Oh, God.

Reasonable quota derivation (please provide usage scenarios, expected number of users, user frequency, peak hours, average duration)/Words):