src/API/Implementation/TTS/IbmWatson/IbmWatsonTtsApi.php
protected function createTextToSpeechContext(
        string $text,
        Language $language,
        TtsAudioFormat $format,
        array $additionalData = []
    ): RequestContext {
        $requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TEXT_TO_SPEECH_API_PATH)))
            ->setRequestParameters(
                array_filter(
                    [
                        'accept' => $this->getAcceptParameter($format, $additionalData),
                        'voice' => $this->getVoiceParameter($language, $additionalData)
                    ]
                )
            )
            ->setData(json_encode(['text' => $text]))
            ->setMethod(RequestContext::METHOD_POST)
            ->setContentType(RequestContext::CONTENT_TYPE_JSON)
            ->setResponseContextClass(DummyResponseContext::class);

        return $this->authorizeRequest($requestContext);
    }
protected function createTextToSpeechContext(
        string $text,
        Language $language,
        TtsAudioFormat $format,
        array $additionalData = []
    ): RequestContext {
        $requestContext = (new RequestContext(sprintf("%s/%s", $this->apiEndpoint, self::TEXT_TO_SPEECH_API_PATH)))
            ->setRequestParameters(
                array_filter(
                    [
                        'accept' => $this->getAcceptParameter($format, $additionalData),
                        'voice' => $this->getVoiceParameter($language, $additionalData)
                    ]
                )
            )
            ->setData(json_encode(['text' => $text]))
            ->setMethod(RequestContext::METHOD_POST)
            ->setContentType(RequestContext::CONTENT_TYPE_JSON)
            ->setResponseContextClass(DummyResponseContext::class);

        return $this->authorizeRequest($requestContext);
    }
protected function createTextToSpeechContext ( string $ text , Language $ language , TtsAudioFormat $ format , array $ additionalData = [ ] ) : RequestContext { $ requestContext = ( new RequestContext ( sprintf ( "%s/%s" , $ this -> apiEndpoint , self :: TEXT_TO_SPEECH_API_PATH ) ) ) -> setRequestParameters ( array_filter ( [ 'accept' => $ this -> getAcceptParameter ( $ format , $ additionalData ) , 'voice' => $ this -> getVoiceParameter ( $ language , $ additionalData ) ] ) ) -> setData ( json_encode ( [ 'text' => $ text ] ) ) -> setMethod ( RequestContext :: METHOD_POST ) -> setContentType ( RequestContext :: CONTENT_TYPE_JSON ) -> setResponseContextClass ( DummyResponseContext :: class ) ; return $ this -> authorizeRequest ( $ requestContext ) ; }
Create request context for text-to-speech request

@param string         $text
@param Language       $language
@param TtsAudioFormat $format
@param array          $additionalData

@return RequestContext

@throws RequestContextException
@throws InvalidVoiceCodeException
@throws InvalidAudioFormatCodeException
@throws InvalidVoiceParametersException
@throws InvalidAudioFormatParameterException
Create request context for text - to - speech request