Was this page helpful?

FreePBX14(CentOS7)

    系統環境

    • FreePBX 14 Distro
    • Asterisk 14.7.4
    • CentOS 7.4

    安裝步驟

    預設環境已經支援 Festival 英文 TTS,如果有需要 Spanish TTS,還要另外安裝以下語音套件

    yum install hispavoces-pal-diphone.noarch hispavoces-sfl-diphone.noarch
    

    TIPs:

    hispavoces-pal-diphone.noarch : Male Spanish voice «PAL» for Festival
    hispavoces-sfl-diphone.noarch : Female Spanish voice «SFL» for Festival

    設定步驟

    編輯 /usr/share/festival/lib/festival.scm,在 (provide 'festival) 這行加上以下內容

    ;;; added by alang
    ;; Enable access to localhost (needed by debian users)
    (set! server_access_list '("localhost\\.localdomain" "localhost"))
    
    ;; Command for Asterisk begin
    (define (tts_textasterisk string mode)
    "(tts_textasterisk STRING MODE)
    Apply tts to STRING. This function is specifically designed for
    use in server mode so a single function call may synthesize the string.
    This function name may be added to the server safe functions."
    (let ((wholeutt (utt.synth (eval (list 'Utterance 'Text string)))))
    (utt.wave.resample wholeutt 8000)
    (utt.wave.rescale wholeutt 5)
    (utt.send.wave.client wholeutt)))
    ;; Command for Asterisk end
    
    (provide 'festival)

     編輯 /etc/asterisk/festival.conf

    [general]
    host=localhost
    port=1314
    usecache=yes
    cachedir=/var/spool/asterisk/tmp
    festivalcommand=(tts_textasterisk "%s" 'file)(quit)\n
    

    使用 TTS

    方法一:使用 festival 服務

    啟動 festival 服務

    festial --server 
    或
    festival_server
    或背景執行
    festival_server 2>&1 > /dev/null &  
    

     Asterisk Dialplan

    exten => 9991,1,Answer
     same => n,Festival('We are now doing Festival Test after successful installation')
     same => n,Hangup
    

    方法二:使用 text2wave

    exten => 9991,1,Answer
     same => n,Set(TMP=tts-festival-${UNIQUEID})
     same => n,System(echo "We are now doing Festival Test after successful installation" | /usr/bin/text2wave -scale 1.5 -F 8000 -o /tmp/${TMP}.wav)
     same => n,Playback(/tmp/${TMP})
     same => n,System(rm -f /tmp/${TMP}.wav)
     same => n,Hangup
    

    方法三:整合 multi-tts.agi

    新增 multi-tts.agi,然後在適當的段落加入以下這幾行

        switch ($engine) {
    ...
            case 'festival':
                exec("echo '$text' | /usr/bin/text2wave -scale 1.5 -F 8000 -o $audiofile.wav");
                break;
    ... 
    

    TTS with Spanish

    NOTE: 若使用方法一,無法正常運作,只能用 text2wave。

    -scale 音量

    -eval 對應的語音檔,語法是 (voice_{語音檔名稱}) 符號括弧不可省略

    exten => 9991,1,Answer
     same => n,Set(TMP=tts-festival-${UNIQUEID})
     same => n,System(echo "Hola, esto es una prueba de la voz en español" | /usr/bin/text2wave -scale 1.5 -F 8000 -eval "(voice_JuntaDeAndalucia_es_pa_diphone)" -o /tmp/${TMP}.wav)
     same => n,Playback(/tmp/${TMP})
     same => n,System(rm -f /tmp/${TMP}.wav)
     same => n,Hangup
    

    其他技巧

    檢查可用哪些語音檔

    方法一:檢查安裝目錄

    [[email protected] ~]# tree /usr/share/festival/lib/voices
    /usr/share/festival/lib/voices
    ├── es
    │   ├── JuntaDeAndalucia_es_pa_diphone
    │   │   ├── festvox
    │   │   │   ├── JuntaDeAndalucia_es_pa_contourmodel_f0.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_diphone.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_duration.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_durdata.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_durtreeZ_dur.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_f0model.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_intonation.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_lexicon.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_other.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_phoneset.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_phrasing.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_tagger.scm
    │   │   │   ├── JuntaDeAndalucia_es_pa_tokenizer.scm
    │   │   │   └── tree_f0.scm
    │   │   └── group
    │   │       └── palpc16k.group
    │   └── JuntaDeAndalucia_es_sf_diphone
    │       ├── festvox
    │       │   ├── JuntaDeAndalucia_es_sf_contourmodel_f0.scm
    │       │   ├── JuntaDeAndalucia_es_sf_diphone.scm
    │       │   ├── JuntaDeAndalucia_es_sf_duration.scm
    │       │   ├── JuntaDeAndalucia_es_sf_durdata.scm
    │       │   ├── JuntaDeAndalucia_es_sf_durtreeZ_dur.scm
    │       │   ├── JuntaDeAndalucia_es_sf_f0model.scm
    │       │   ├── JuntaDeAndalucia_es_sf_intonation.scm
    │       │   ├── JuntaDeAndalucia_es_sf_lexicon.scm
    │       │   ├── JuntaDeAndalucia_es_sf_other.scm
    │       │   ├── JuntaDeAndalucia_es_sf_phoneset.scm
    │       │   ├── JuntaDeAndalucia_es_sf_phrasing.scm
    │       │   ├── JuntaDeAndalucia_es_sf_tagger.scm
    │       │   ├── JuntaDeAndalucia_es_sf_tokenizer.scm
    │       │   └── tree_f0.scm
    │       └── group
    │           └── sflpc16k.group
    └── us
        └── nitech_us_slt_arctic_hts
            ├── festvox
            │   ├── nitech_us_slt_arctic_clunits.scm
            │   ├── nitech_us_slt_arctic_duration.scm
            │   ├── nitech_us_slt_arctic_durdata.scm
            │   ├── nitech_us_slt_arctic_f0model.scm
            │   ├── nitech_us_slt_arctic_hts.scm
            │   ├── nitech_us_slt_arctic_intonation.scm
            │   ├── nitech_us_slt_arctic_lexicon.scm
            │   ├── nitech_us_slt_arctic_other.scm
            │   ├── nitech_us_slt_arctic_phoneset.scm
            │   ├── nitech_us_slt_arctic_phrasing.scm
            │   ├── nitech_us_slt_arctic_tagger.scm
            │   └── nitech_us_slt_arctic_tokenizer.scm
            └── hts
                ├── duration.pdf
                ├── feat.list
                ├── lf0_acc.win
                ├── lf0_dyn.win
                ├── lf0.pdf
                ├── mcep_acc.win
                ├── mcep_dyn.win
                ├── mcep.pdf
                ├── p_mcep.pdf
                ├── trees-dur.inf
                ├── trees-lf0.inf
                └── trees-mcep.inf
    
    11 directories, 54 files
    

    方法二:進入 festival

    #> festival
    
    festival> (voice.list)
    (nitech_us_slt_arctic_hts
     JuntaDeAndalucia_es_pa_diphone
     JuntaDeAndalucia_es_sf_diphone)
    
    安裝其他語音檔
    [[email protected] ~]# yum search festvox
    Loaded plugins: fastestmirror, versionlock
    Loading mirror speeds from cached hostfile
    ===================================== N/S matched: festvox =====================================
    festvox-awb-arctic-hts.noarch : Scottish-accent US English male speaker "AWB" for Festival
    festvox-bdl-arctic-hts.noarch : US English male speaker "BDL" for Festival
    festvox-clb-arctic-hts.noarch : US English female speaker "CLB" for Festival
    festvox-jmk-arctic-hts.noarch : Canadian-accent US English male speaker "JMK" for Festival
    festvox-kal-diphone.noarch : American English male speaker "Kevin" for Festival
    festvox-ked-diphone.noarch : American English male speaker "Kurt" for Festival
    festvox-rms-arctic-hts.noarch : US English male speaker "RMS" for Festival
    festvox-slt-arctic-hts.noarch : US English female speaker "SLT" for Festival
    
    Was this page helpful?
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core