提交语音

@param accessToken 接口调用凭证
@param voiceId     语音唯一标识
@param inputStream 文件格式 只支持mp3，16k，单声道，最大1M
@return BaseResult
@since 2.8.22
169816
public static BaseResult addvoicetorecofortext(String accessToken, String voiceId, InputStream inputStream) {
        return addvoicetorecofortext(accessToken, voiceId, null, inputStream);
    }
326710
public static CreateResult create(String accessToken, Create<?> card) {
		return create(accessToken, JsonUtil.toJSONString(card));
	}
102530
public void setAccessToken(String accessToken, String tokenType) throws HelloSignException {
        auth.setAccessToken(accessToken, tokenType);
    }
746332
public VoiceCallResponse viewVoiceCall(final String id) throws NotFoundException, GeneralException, UnauthorizedException {
        if (id == null) {
            throw new IllegalArgumentException("Voice Message ID must be specified.");
        }

        String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH);
        return messageBirdService.requestByID(url, id, VoiceCallResponse.class);
    }
599621
public static SemproxySearchResult semproxySearch(String accessToken, SemproxySearch semproxySearch) {
        return semproxySearch(accessToken, JsonUtil.toJSONString(semproxySearch));
    }
316589
public static void main(final String[] args) throws Exception {
    SpeechToText service = new SpeechToText();
    IamOptions options = new IamOptions.Builder()
        .apiKey("<iam_api_key>")
        .build();
    service.setIamCredentials(options);

    // Signed PCM AudioFormat with 16kHz, 16 bit sample size, mono
    int sampleRate = 16000;
    AudioFormat format = new AudioFormat(sampleRate, 16, 1, true, false);
    DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);

    if (!AudioSystem.isLineSupported(info)) {
      System.out.println("Line not supported");
      System.exit(0);
    }

    TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);
    line.open(format);
    line.start();

    AudioInputStream audio = new AudioInputStream(line);

    RecognizeOptions options = new RecognizeOptions.Builder()
        .audio(audio)
        .interimResults(true)
        .timestamps(true)
        .wordConfidence(true)
        //.inactivityTimeout(5) // use this to stop listening when the speaker pauses, i.e. for 5s
        .contentType(HttpMediaType.AUDIO_RAW + ";rate=" + sampleRate)
        .build();

    service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() {
      @Override
      public void onTranscription(SpeechRecognitionResults speechResults) {
        System.out.println(speechResults);
      }
    });

    System.out.println("Listening to your voice for the next 30s...");
    Thread.sleep(30 * 1000);

    // closing the WebSockets underlying InputStream will close the WebSocket itself.
    line.stop();
    line.close();

    System.out.println("Fin.");
  }
1285256
public static BaseResult addvoicetorecofortext(String accessToken, String voiceId, String lang, File voice) {
        HttpPost httpPost = new HttpPost(BASE_URI + "/cgi-bin/media/voice/addvoicetorecofortext");
        FileBody bin = new FileBody(voice);
        HttpEntity reqEntity = MultipartEntityBuilder.create()
                .addPart("media", bin)
                .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(accessToken))
                .addTextBody("format", MediaType.voice_mp3.fileSuffix())
                .addTextBody("voice_id", voiceId)
                .addTextBody("lang", lang == null || lang.isEmpty() ? "zh_CN" : lang)
                .build();
        httpPost.setEntity(reqEntity);

        return LocalHttpClient.executeJsonResult(httpPost, BaseResult.class);
    }
325160
public static MaterialAddResult materialAdd(String accessToken,
                                                MediaType type, InputStream inputStream) {
        HttpPost httpPost = new HttpPost(BASE_URI + "/shakearound/material/add");
        byte[] data;
        try {
            data = StreamUtils.copyToByteArray(inputStream);
        } catch (IOException e) {
            logger.error("", e);
            throw new RuntimeException(e);
        }

        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder
                .create().addBinaryBody("media", data, ContentType.DEFAULT_BINARY, "temp." + type.fileSuffix());
        HttpEntity reqEntity = multipartEntityBuilder
                .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(accessToken))
                .addTextBody("type", type.uploadType()).build();
        httpPost.setEntity(reqEntity);

        return LocalHttpClient.executeJsonResult(httpPost,
                MaterialAddResult.class);
    }
745983
static String getAccessTokenForUserId(String userId) {
        if (userId == null && getUserId() == null
                || userId != null && userId.equals(getUserId())) {
            return getAccessToken();
        } else {
            JSONObject usersArchive = getJSONObject(PER_USER_ARCHIVE_PREF_NAME);
            if (usersArchive == null) usersArchive = new JSONObject();
            JSONObject userArchive = usersArchive.optJSONObject(userId == null ? "" : userId);
            if (userArchive == null) userArchive = new JSONObject();
            return JSONUtil.optString(userArchive, ACCESS_TOKEN_PREF_NAME);
        }
    }
863748
public DConnection findByAccessToken(java.lang.String accessToken) {
    return queryUniqueByField(null, DConnectionMapper.Field.ACCESSTOKEN.getFieldName(), accessToken);
  }
1157761
@Deprecated
    BasicUser getCurrentUserBasic(AccessToken accessToken) {
        checkAccessTokenIsNotNull(accessToken);

        StatusType status;
        String content;
        try {
            Response response = targetEndpoint.path("me").request(MediaType.APPLICATION_JSON)
                    .header("Authorization", BEARER + accessToken.getToken())
                    .property(ClientProperties.CONNECT_TIMEOUT, getConnectTimeout())
                    .property(ClientProperties.READ_TIMEOUT, getReadTimeout())
                    .get();

            status = response.getStatusInfo();
            content = response.readEntity(String.class);
        } catch (ProcessingException e) {
            throw new ConnectionInitializationException(CONNECTION_SETUP_ERROR_STRING, e);
        }

        checkAndHandleResponse(content, status, accessToken);

        return mapToType(content, BasicUser.class);
    }
995420
public static DeviceGroupAddResult deviceGroupAdd(String accessToken,
                                                      DeviceGroupAdd deviceGroupAdd) {
        return deviceGroupAdd(accessToken,
                JsonUtil.toJSONString(deviceGroupAdd));
    }
1242420
function joinVoiceChannel(client, voiceSession) {
	var vWS, vUDP, endpoint = voiceSession.endpoint.split(":")[0];
	//handleVoiceChannelChange(client, voiceSession);

	voiceSession.ws = {};
	voiceSession.udp = {};
	voiceSession.members = {};
	voiceSession.error = null;
	voiceSession.ready = false;
	voiceSession.joined = false;
	voiceSession.translator = {};
	voiceSession.wsKeepAlive = null;
	voiceSession.udpKeepAlive = null;
	voiceSession.keepAlivePackets = 0;
	voiceSession.emitter = new Emitter();
	if (isNode) voiceSession.keepAliveBuffer = new Buffer(8).fill(0);
	vWS = voiceSession.ws.connection = new Websocket("wss://" + endpoint);

	if (isNode) return DNS.lookup(endpoint, function(err, address) {
		if (err) return void(voiceSession.error = err);

		voiceSession.address = address;
		vUDP = voiceSession.udp.connection = UDP.createSocket("udp4");

		vUDP.bind({exclusive: true});
		vUDP.once('message', handleUDPMessage.bind(client, voiceSession));

		vWS.once('open',  handlevWSOpen.bind(client, voiceSession));
		vWS.on('message', handlevWSMessage.bind(client, voiceSession));
		vWS.once('close', handlevWSClose.bind(client, voiceSession));
	});

	vWS.once('open',  handlevWSOpen.bind(client, voiceSession));
	vWS.on('message', handlevWSMessage.bind(client, voiceSession));
	vWS.once('close', handlevWSClose.bind(client, voiceSession));
	return void(voiceSession.joined = true);
}
1326139
function AudioCB(voiceSession, audioChannels, encoder, maxStreamSize) {
	//With the addition of the new Stream API, `playAudioFile`, `stopAudioFile` and `send`
	//will be removed. However they're deprecated for now, hence the code repetition.
	if (maxStreamSize && !Opus) Opus = require('cjopus');
	Stream.Duplex.call(this);
	var ACBI = this;

	this.audioChannels = audioChannels;
	this.members = voiceSession.members;

	applyProperties(this, [
		["_sequence", 0],
		["_timestamp", 0],
		["_readable", false],
		["_streamRef", null],
		["_startTime", null],
		["_systemEncoder", null],
		["_playingAudioFile", false],
		["_voiceSession", voiceSession],
		["_port", voiceSession.ws.port],
		["_address", voiceSession.address],
		["_decodeNonce", new Uint8Array(24)],
		["_vUDP", voiceSession.udp.connection],
		["_secretKey", new Uint8Array(voiceSession.secretKey)],
		["_mixedDecoder", Opus && new Opus.OpusEncoder( 48000, audioChannels ) || null]
	]);

	createAudioEncoder(this, encoder);

	this._write = function _write(chunk, encoding, callback) {
		ACBI._systemEncoder.stdin.write(chunk);
		return callback();
	};
	this._read = function _read() {};
	this.stop = function stop() {
		return this._systemEncoder.stdout.read = function() { return null };
	};

	if (maxStreamSize) {
		voiceSession.ws.connection.on('message', function(data, flags) {
			data = decompressWSMessage(data, flags);

			if (data.op !== 5) return;
			if (!voiceSession.members[data.d.user_id]) {
				voiceSession.members[data.d.user_id] = new Stream.Readable({
					highWaterMark: maxStreamSize,
					read: function(s) {}
				});
				voiceSession.members[data.d.user_id].decoder = new Opus.OpusEncoder( 48000, ACBI.audioChannels );
				ACBI.emit('newMemberStream', data.d.user_id, voiceSession.members[data.d.user_id]);
			}

			voiceSession.members[data.d.user_id].ssrc = data.d.ssrc;
			voiceSession.translator[data.d.ssrc] = voiceSession.members[data.d.user_id];
		});
		this._vUDP.on('message', handleIncomingAudio.bind(this));
	}
}
187250
public static BaseResult codeUpdate(String accessToken, CodeUpdate codeUpdate) {
		return codeUpdate(accessToken, JsonUtil.toJSONString(codeUpdate));
	}
97495
public static BaseResult addvoicetorecofortext(String accessToken, String voiceId, File voice) {
        return addvoicetorecofortext(accessToken, voiceId, null, voice);
    }
1033136
public static TranslatecontentResult translatecontent(String accessToken, String lfrom, String lto, File content, String charsetName) {
        HttpPost httpPost = new HttpPost(BASE_URI + "/cgi-bin/media/voice/translatecontent");

        byte[] data;
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(content), charsetName))) {
            String line;
            StringBuilder sb = new StringBuilder();

            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }

            data = sb.toString().getBytes("UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }

        HttpEntity reqEntity = MultipartEntityBuilder.create()
                .addBinaryBody("media", data, ContentType.DEFAULT_BINARY, "temp.txt")
                .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(accessToken))
                .addTextBody("lfrom", lfrom)
                .addTextBody("lto", lto)
                .build();
        httpPost.setEntity(reqEntity);

        return LocalHttpClient.executeJsonResult(httpPost, TranslatecontentResult.class);
    }