You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.1 KiB
60 lines
1.1 KiB
<?php
|
|
|
|
namespace app\base\controller\demo\api;
|
|
|
|
|
|
use think\App;
|
|
|
|
class Pinyin extends Base
|
|
{
|
|
|
|
/**
|
|
* 文字转语音
|
|
* @date 2022-05-13
|
|
*/
|
|
public function textToPinyin()
|
|
{
|
|
$param = input('post.');
|
|
|
|
$pinyin_class = new \pinyin\Pinyin();
|
|
|
|
//汉字转成拼音
|
|
$result = $pinyin_class->textToPinyin($param['text'], PINYIN_TONE);
|
|
|
|
//记录日志
|
|
platformLog([
|
|
'text' => $param['text'],
|
|
'options' => PINYIN_TONE
|
|
], $result, 'pinyin_text_to_pinyin_' . UID);
|
|
|
|
|
|
dump($result);
|
|
}
|
|
|
|
/**
|
|
* 句子转拼音(带标点符号)
|
|
* @date 2022-05-13
|
|
*/
|
|
public function sentenceToPinyin()
|
|
{
|
|
$param = input('post.');
|
|
|
|
$pinyin_class = new \pinyin\Pinyin();
|
|
|
|
//句子转拼音(带标点符号)
|
|
$result = $pinyin_class->sentenceToPinyin($param['text'], PINYIN_TONE, '-');
|
|
|
|
//记录日志
|
|
platformLog([
|
|
'text' => $param['text'],
|
|
'options' => PINYIN_TONE,
|
|
'delimter' => '-'
|
|
], $result, 'pinyin_entence_to_pinyin_' . UID);
|
|
|
|
|
|
dump($result);
|
|
}
|
|
|
|
|
|
}
|