更新正则
This commit is contained in:
parent
a6407044ff
commit
ddd75f8a00
@ -95,20 +95,9 @@ class Pusher
|
||||
}
|
||||
$connection->send($response);
|
||||
} else {
|
||||
$a=$resp['payload']['choices']['text'][0]['content'];
|
||||
if(strlen($a)>0){
|
||||
$pattern = "/[。]/";
|
||||
if (preg_match($pattern, $a)) {
|
||||
$resp['payload']['choices']['tts_text'] = $text;
|
||||
} else {
|
||||
$resp['payload']['choices']['tts_text'] = $text.$a;
|
||||
// $this->tts($text.$a);
|
||||
|
||||
}
|
||||
}else{
|
||||
$resp['payload']['choices']['tts_text'] = $text.$a;
|
||||
// $this->tts($text.$a);
|
||||
}
|
||||
$resp['payload']['choices']['tts_text'] = $text.$resp['payload']['choices']['text'][0]['content'];
|
||||
// $this->tts($text.$a);
|
||||
$text = '';
|
||||
$response = json_encode($resp, true);
|
||||
|
||||
|
@ -56,7 +56,8 @@ class IndexController
|
||||
|
||||
public function tts(Request $request){
|
||||
$text = $request->post('data');
|
||||
if($text!=''){
|
||||
$pattern = "/[\x{4e00}-\x{9fa5}\d]+/u";
|
||||
if( preg_match($pattern, $text)){
|
||||
$name = time() . rand(1, 100000) . '.mp3';
|
||||
$tts = new TtsClient($this->app_id, $this->api_key, $this->api_secret, $this->ttsConfig);
|
||||
file_put_contents(public_path('tts') . '/' . $name, $tts->request($text)->getBody()->getContents());
|
||||
|
Loading…
x
Reference in New Issue
Block a user