<?php
class Speech extends BaseSerevice {
public $callBackData;
function __construct(TranslateService $TG, $callbackData){
parent::__construct($TG);
$this->callBackData = $callbackData;
}
function listen(){
if($this->callBackData[0] != EnumSpeech::SPEECH_GET_SOUND){
return false;
}
$word = $this->callBackData[1];
$soundLink = $this->getTG()->getTTS()->getSoundFromGoogle($word);
// if(!file_exists($soundLink)){
// $voice = $this->TG->getSpeech ($word);
// if(!isset($voice ['error'])){
// $soundFile= $this->TG->normalizeGermanWord($word).".mp3";
// file_put_contents ( "sounds/" . $soundFile, $voice ['response'] );
// }
// else{
// $this->TG->sendMessage ("error".$voice ['error']);
// }
// }
// $result = $this->TG->apiRequestWebhook("sendAudio", array(
$result = $this->getTG()->apiRequest("sendAudio", array(
'chat_id' => $this->getTG()->chat_id,
"audio" => $soundLink,
'caption' => "@TranslateGerman_bot" . PHP_EOL . "تلفظ " . $word
));
return $textCallback = "تلفظ ارسال شد";
}
/*
*
* if($callBackData[0] == "task" && $callBackData[1] == "translate"){
// $key = "trnsl.1.1.20161227T200147Z.ea68ee52a784814b.d57d90672c621ed4b707e054a845d8e0367ad95d";
// $translated = file_get_contents("https://translate.yandex.net/api/v1.5/tr.json/translate?key="
// .$key."&lang=de-fa&text=abmachen");
$key="trnsl.1.1.20161227T200147Z.ea68ee52a784814b.d57d90672c621ed4b707e054a845d8e0367ad95d";
$translator = new Translator($key);
$message = $translator->translate($this->message['text'], "de-fa");
}
else
*
*/
}
?>