2025/9/15

Container vs VM

Container 是類似 docker 這樣建構在某個 OS 的虛擬機器,VM 是類似 Hypervisor VMWare 建立的虛擬機器。

VM

優點:

  • 從硬體開始就虛擬化,機器獨立

  • 可在不同 VM 安裝不同的 OS

  • 不同應用程式內的相關套件耦合,不會互相影響

  • 適合比較大型,需要很多不同的整合服務的應用

缺點:

  • 耗用的硬碟空間較多,使用的硬體資源比較高

  • 啟動服務需要比較長的時間

Container

優點:

  • 檔案比較小

  • 啟動速度快

  • 耗用系統資源比較少

  • 容易更新

  • 通常以應用程式為單位

缺點:

  • 主要依賴 Host OS的操作,無法同時安裝不同的 OS

  • container 之間的元件部署比較複雜

2025/9/8

Open Street Map Local Server

Switch2OSM

https://switch2osm.org/

因為 Open Street Map 的免費公用特性,所以我們可以複製這些地圖資料到自己的地圖 server,Switch2OSM 是一個推廣 OSM 的專案,我們可以透過這個專案,建置自己的 Map Server

PBF format

.pbf空間數據詳解

PBF 就是 Protocolbuffer Binary Format 這是基於 ProtoBuffer 的一種 binary data format,這是一種比 XML, GeoJSON 等等地圖格式還要精簡的檔案格式。

在 OSM 通常是以 *.osm.pbf 這個 file extension 代表 OSM PBF file

Open Street Map 在 PBF Format - OpenStreetMap Wiki 有說明該檔案格式的定義。

Taiwan OSM

Geofabrik Download Server Taiwan 這個網站,有固定更新從 Open Street Map 下載的 Taiwan 離線地圖,我們可以到這個網站下載 taiwan-latest.osm.pbf

取得 osm PBF 檔案以後,就可以匯入 switch2osm local map server

docker

參考 Using a Docker container – Switch2OSM 的說明,最簡單的方式就是透過 container 建置 switch2osm

以下以 Redhat 系列的 podman 進行測試

匯入 osm.pbf 檔案

podman volume create osm-data

podman run  --name osmtile-import -v /root/download/osm/taiwan-latest.osm.pbf:/data/region.osm.pbf  -v osm-data:/data/database/  overv/openstreetmap-tile-server  import

tile server

podman volume create osm-tiles
# 啟動 tile server
podman run --name osmtile -p 8081:80 -v osm-data:/data/database/ -v osm-tiles:/data/tiles -d overv/openstreetmap-tile-server run

啟動後就可以在 http://localhost:8081/tile/ 看到透過 Leaflet 取得的 OSM 地圖

2025/9/1

WhisperSpeech

WhisperSpeech是一種反轉Whisper技術,實做的TTS系統。

安裝測試

在 Rocky Linux 8 的 Python 3.11 安裝測試

dnf install python3.11
# 在執行測試時,會需要 python.h,故需要安裝 devel 套件
dnf install python3.11-devel

python3 -m venv /root/venv/whisperspeech
source /root/venv/whisperspeech/bin/activate

pip3 install WhisperSpeech
pip3 install webdataset

測試程式

import torch
import torch.nn.functional as F
from whisperspeech.pipeline import Pipeline

pipe = Pipeline(s2a_ref='collabora/whisperspeech:s2a-q4-tiny-en+pl.model', torch_compile=True)
pipe.generate_to_file("output.wav", "Hello from WhisperSpeech.")

以 time 測試執行時間

time python3 test.py
real    0m38.452s
user    2m19.176s
sys    0m1.683s

真實時間大約花了 40s,這邊是用 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 的機器,沒有用到 GPU

這個網站可以聽到 WhisperSpeech 產生的語音結果

WhisperSpeech - New Text-To-Speech Model In Town

References

GitHub - WhisperSpeech/WhisperSpeech: An Open Source text-to-speech system built by inverting Whisper.

whisperspeech 英文TTS的实现_whisper speech-CSDN博客

2025/8/25

Spring Boot 3 JPA multiple datasource

在一個 Spring Boot 3 project 同時連接到兩個 database,需要用兩個設定檔指定兩個 datasource,分別設定不同的 entityManager, transactonManager, jdbcTemplate。

  • application.yml

    spring:
      application:
        name: project
      jpa:
        properties:
          hibernate:
            # dialect: org.hibernate.dialect.MySQLDialect
            dialect: org.hibernate.community.dialect.MySQLLegacyDialect
    
    project:
      kokods:
        url: jdbc:mariadb://localhost:3306/koko
        username: root
        password: password
        schema: koko
        type: com.zaxxer.hikari.HikariDataSource
        hikari:
          connection-timeout: 30000 # milliseconds that a client will wait for a new connection from the pool  30 seconds
          minimum-idle: 1           # minimum number of idle connections
          maximum-pool-size: 100    # maximum number of connections
          idle-timeout: 600000      # maximum amount of time that a connection may sit idle in the pool of connections  10 mins
          max-lifetime: 1800000     # a connection can be pooled for before being destroyed  30 mins
          auto-commit: true
          connection-test-query: SELECT CURRENT_TIMESTAMP
      db2ds:
        url: jdbc:mariadb://localhost:3306/db2
        username: root
        password: password
        schema: db2
        type: com.zaxxer.hikari.HikariDataSource
        hikari:
          connection-timeout: 30000 # milliseconds that a client will wait for a new connection from the pool  30 seconds
          minimum-idle: 1           # minimum number of idle connections
          maximum-pool-size: 100    # maximum number of connections
          idle-timeout: 600000      # maximum amount of time that a connection may sit idle in the pool of connections  10 mins
          max-lifetime: 1800000     # a connection can be pooled for before being destroyed  30 mins
          auto-commit: true
          connection-test-query: SELECT CURRENT_TIMESTAMP
    
    logging:
      level:
        com.zaxxer.hikari: TRACE
        com.zaxxer.hikari.HikariConfig: DEBUG
  • @Configuration設定

    • KoKoConfig.java

      package tw.com.maxkit.koko.config;
      
      import com.zaxxer.hikari.HikariDataSource;
      import org.springframework.beans.factory.annotation.Qualifier;
      import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
      import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
      import org.springframework.context.annotation.*;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.boot.context.properties.ConfigurationProperties;
      import org.springframework.boot.jdbc.DataSourceBuilder;
      import org.springframework.core.env.Environment;
      import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
      import org.springframework.jdbc.core.JdbcTemplate;
      import org.springframework.orm.jpa.JpaTransactionManager;
      import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
      import org.springframework.transaction.PlatformTransactionManager;
      import org.springframework.transaction.annotation.EnableTransactionManagement;
      
      import javax.sql.DataSource;
      
      @Configuration
      //@PropertySource({"classpath:persistence-multiple-db.properties"})
      @EnableJpaRepositories(
              basePackages = "tw.com.maxkit.koko.dao.jpa",
              entityManagerFactoryRef = "kokoEntityManagerFactory",
              transactionManagerRef = "kokoTransactionManager"
      )
      @EnableTransactionManagement
      public class KoKoConfig {
          @Autowired
          private Environment env;
      
          @Primary
          @Bean("kokoDataSourceProperties")
          @ConfigurationProperties("project.kokods")
          public DataSourceProperties kokoDataSourceProperties() {
              return new DataSourceProperties();
          }
      
          @Primary
          @Bean("kokoDataSource")
          @Qualifier(value="kokoDataSourceProperties")
          @ConfigurationProperties(prefix = "project.kokods.hikari")
          public HikariDataSource kokoDataSource() {
              return kokoDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
          }
      
          // 如果不修改 Hikari 的參數,可直接使用這個 datasource,但要注意設定檔 url 要改為 jdbc-url
      //    @Bean("lartelDataSource")
      //    @ConfigurationProperties("lartel.kokods")
      //    public DataSource lartelDataSource() {
      //        return DataSourceBuilder.create().build();
      //    }
      
          @Primary
          @Bean("kokoEntityManagerFactory")
          public LocalContainerEntityManagerFactoryBean kokoEntityManagerFactory(
                  @Qualifier("kokoDataSource") DataSource kokoDataSource,
                  EntityManagerFactoryBuilder builder) {
              return builder //
                      .dataSource(kokoDataSource) //
                      .packages("tw.com.maxkit.koko.data.entity") //
                      .persistenceUnit("kokoDs") //
                      .build();
          }
      
          @Primary
          @Bean("kokoTransactionManager")
          public PlatformTransactionManager kokoTransactionManager(
                  @Qualifier("kokoEntityManagerFactory") LocalContainerEntityManagerFactoryBean kokoEntityManagerFactory) {
              return new JpaTransactionManager(kokoEntityManagerFactory.getObject());
          }
      
          @Primary
          @Bean("kokoJdbcTemplate")
          public JdbcTemplate kokoJdbcTemplate(
                  @Qualifier("kokoDataSource") DataSource kokoDataSource) {
              return new JdbcTemplate(kokoDataSource);
          }
      }
    • Db2Config.java

      package tw.com.maxkit.db2.config;
      
      import com.zaxxer.hikari.HikariDataSource;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.beans.factory.annotation.Qualifier;
      import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
      import org.springframework.boot.context.properties.ConfigurationProperties;
      import org.springframework.boot.jdbc.DataSourceBuilder;
      import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.context.annotation.Primary;
      import org.springframework.core.env.Environment;
      import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
      import org.springframework.jdbc.core.JdbcTemplate;
      import org.springframework.orm.jpa.JpaTransactionManager;
      import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
      import org.springframework.transaction.PlatformTransactionManager;
      import org.springframework.transaction.annotation.EnableTransactionManagement;
      
      import javax.sql.DataSource;
      
      @Configuration
      @EnableJpaRepositories(
              basePackages = "tw.com.maxkit.db2.dao.jpa",
              entityManagerFactoryRef = "lartelEntityManagerFactory",
              transactionManagerRef = "lartelTransactionManager"
      )
      @EnableTransactionManagement
      public class LartelConfig {
          @Autowired
          private Environment env;
      
          // 這兩個 method 會套用修改 Hikari 的參數
          @Bean("db2DataSourceProperties")
          @ConfigurationProperties("project.db2ds")
          public DataSourceProperties db2DataSourceProperties() {
              return new DataSourceProperties();
          }
      
          @Bean("db2DataSource")
          @Qualifier(value="db2DataSourceProperties")
          @ConfigurationProperties(prefix = "project.db2ds.hikari")
          public HikariDataSource db2DataSource() {
              return db2DataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
          }
      
          // 如果不修改 Hikari 的參數,可直接使用這個 datasource,但要注意設定檔 url 要改為 jdbc-url
      //    @Bean("lartelDataSource")
      //    @ConfigurationProperties("lartel.lartelds")
      //    public DataSource lartelDataSource() {
      //        return DataSourceBuilder.create().build();
      //    }
      
          @Bean("db2EntityManagerFactory")
          public LocalContainerEntityManagerFactoryBean db2EntityManagerFactory(
                  @Qualifier("db2DataSource") DataSource db2DataSource,
                  EntityManagerFactoryBuilder builder) {
              return builder //
                      .dataSource(db2DataSource) //
                      .packages("tw.com.maxkit.db2.data.entity") //
                      .persistenceUnit("db2Ds") //
                      .build();
          }
      
          @Bean("db2TransactionManager")
          public PlatformTransactionManager db2TransactionManager(
                  @Qualifier("db2EntityManagerFactory") LocalContainerEntityManagerFactoryBean lartelEntityManagerFactory) {
              return new JpaTransactionManager(db2EntityManagerFactory.getObject());
          }
      
          @Bean("db2JdbcTemplate")
          public JdbcTemplate db2JdbcTemplate(
                  @Qualifier("db2DataSource") DataSource db2DataSource) {
              return new JdbcTemplate(db2DataSource);
          }
      }
  • 第一個 datasource 部分的 DAO,另一個是類似的作法

    package tw.com.maxkit.koko.dao.jpa;
    
    import org.springframework.data.jpa.repository.JpaRepository;
    import org.springframework.stereotype.Repository;
    import tw.com.maxkit.koko.data.entity.Uservo;
    
    import java.util.List;
    
    @Repository
    public interface UservoDAO extends JpaRepository<Uservo, Long> {
        public List<Uservo> queryAll();
    }
    • DAO 的 implementation

      package tw.com.maxkit.koko.dao.jpa;
      
      import jakarta.persistence.EntityManager;
      import jakarta.persistence.TypedQuery;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.data.jpa.repository.JpaContext;
      import org.springframework.stereotype.Component;
      import tw.com.maxkit.koko.data.entity.Uservo;
      
      import java.util.List;
      
      @Component
      public class UservoDAOImpl {
          private final EntityManager em;
      
          @Autowired
          public UservoDAOImpl(JpaContext context) {
              this.em = context.getEntityManagerByManagedType(Uservo.class);
          }
      
          public List queryAll() {
              String jpql = "SELECT u FROM Uservo u";
              TypedQuery query = this.em.createQuery(jpql, Uservo.class);
              return query.getResultList();
          }
      }
  • Service

    package tw.com.maxkit.koko.service;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
    import tw.com.maxkit.koko.dao.jpa.UservoDAO;
    import tw.com.maxkit.koko.data.entity.Uservo;
    
    @Service
    public class UservoService {
    
        @Autowired
        private UservoDAO uservoDAO;
    
        public void findAll() {
            System.out.println("\n使用 Spring Data JPA 衍生方法查詢 uservo 的資料:");
    //        this.uservoRepository.findAll().forEach(System.out::println);
            this.uservoDAO.findAll().forEach(
                    uservo -> System.out.println("uservoseq="+uservo.getUservoseq()+", userid="+uservo.getUserid())
            );
        }
    
        @Transactional("kokoTransactionManager")
        public Uservo testTransactional(String userid, String username) {
            // 刪除全部
    //        this.uservoRepository.deleteAll();
    
            // 寫入一筆
            Uservo a = new Uservo();
            a.setUserid(userid);
            a.setUsername(username);
            a = this.uservoDAO.save(a);
    
            // 故意埋入 RuntimeException: ArrayIndexOutOfBoundsException
            System.out.println(new String[] {}[1]);
    
            return a;
        }
    
        public void queryAll() {
            System.out.println("\n使用 queryAll 查詢 uservo 的資料:");
    //        this.uservoRepository.findAll().forEach(System.out::println);
            this.uservoDAO.queryAll().forEach(
                    uservo -> System.out.println("uservoseq="+uservo.getUservoseq()+", userid="+uservo.getUserid())
            );
        }
    }

References

Spring Boot + Spring Data JPA 配置多個 DataSource

HikariCP 连接池多数据源配置

2025/8/18

espeak-ng

How To Install espeak-ng on CentOS 8 | Installati.one

How to install eSpeak on CentOS 8 / Ubuntu 20.04 / 18.04? - Linux Windows and android Tutorials

eSpeak NG 安装和配置指南-CSDN博客

eSpeak NG,適用於 Linux 的文本到語音合成器

eSpeak NG (Next Generation) Text-to-Speech 是 open source speech synthesizer。使用了共振峰合成方法,用比較小的程式提供多種語言的合成方法。

1995年 Jonathan Duddington 提出在 RISC OS 運作,支援 British English 的語音合成器,後來在 2006/2/17,speak 1.05 以 GPLv2 released。目前已重新命名為 eSpeak

2010/6/25 Reece Dunn 在 github 以 1.43.46 版發起 eSpeak 的 fork,致力於讓 eSpeak 運作在其他 POSIX plarforms。到了 2015/12/11 epeak-ng 啟動,支援更多語言,且做了更多 bug fix。

CLI

# espeak-ng --help
eSpeak NG text-to-speech: 1.49.2  Data at: /usr/share/espeak-ng-data

espeak-ng [options] ["<words>"]

-f <text file>   Text file to speak
--stdin    Read text input from stdin instead of a file

If neither -f nor --stdin, then <words> are spoken, or if none then text
is spoken from stdin, each line separately.

-a <integer>
       Amplitude, 0 to 200, default is 100
-d <device>
       Use the specified device to speak the audio on. If not specified, the
       default audio device is used.
-g <integer>
       Word gap. Pause between words, units of 10mS at the default speed
-k <integer>
       Indicate capital letters with: 1=sound, 2=the word "capitals",
       higher values indicate a pitch increase (try -k20).
-l <integer>
       Line length. If not zero (which is the default), consider
       lines less than this length as end-of-clause
-p <integer>
       Pitch adjustment, 0 to 99, default is 50
-s <integer>
       Speed in approximate words per minute. The default is 175
-v <voice name>
       Use voice file of this name from espeak-ng-data/voices
-w <wave file name>
       Write speech to this WAV file, rather than speaking it directly
-b       Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit
-m       Interpret SSML markup, and ignore other < > tags
-q       Quiet, don't produce any speech (may be useful with -x)
-x       Write phoneme mnemonics to stdout
-X       Write phonemes mnemonics and translation trace to stdout
-z       No final sentence pause at the end of the text
--compile=<voice name>
       Compile pronunciation rules and dictionary from the current
       directory. <voice name> specifies the language
--compile-debug=<voice name>
       Compile pronunciation rules and dictionary from the current
       directory, including line numbers for use with -X.
       <voice name> specifies the language
--compile-mbrola=<voice name>
       Compile an MBROLA voice
--compile-intonations
       Compile the intonation data
--compile-phonemes=<phsource-dir>
       Compile the phoneme data using <phsource-dir> or the default phsource directory
--ipa      Write phonemes to stdout using International Phonetic Alphabet
--path="<path>"
       Specifies the directory containing the espeak-ng-data directory
--pho      Write mbrola phoneme data (.pho) to stdout or to the file in --phonout
--phonout="<filename>"
       Write phoneme output from -x -X --ipa and --pho to this file
--punct="<characters>"
       Speak the names of punctuation characters during speaking.  If
       =<characters> is omitted, all punctuation is spoken.
--sep=<character>
       Separate phonemes (from -x --ipa) with <character>.
       Default is space, z means ZWJN character.
--split=<minutes>
       Starts a new WAV file every <minutes>.  Used with -w
--stdout   Write speech output to stdout
--tie=<character>
       Use a tie character within multi-letter phoneme names.
       Default is U+361, z means ZWJ character.
--version  Shows version number and date, and location of espeak-ng-data
--voices=<language>
       List the available voices for the specified language.
       If <language> is omitted, then list all voices.
-h, --help Show this help.
# espeak-ng --voices
Pty Language       Age/Gender VoiceName          File                 Other Languages
 5  af              --/M      Afrikaans          gmw/af
 5  am              --/M      Amharic            sem/am
 5  an              --/M      Aragonese          roa/an
 5  ar              --/M      Arabic             sem/ar
 5  as              --/M      Assamese           inc/as
 5  az              --/M      Azerbaijani        trk/az
 5  bg              --/M      Bulgarian          zls/bg
 5  bn              --/M      Bengali            inc/bn
 5  bpy             --/M      Bishnupriya_Manipuri inc/bpy
 5  bs              --/M      Bosnian            zls/bs
 5  ca              --/M      Catalan            roa/ca
 5  cmn             --/M      Chinese_(Mandarin) sit/cmn              (zh-cmn 5)(zh 5)
 5  cs              --/M      Czech              zlw/cs
 5  cy              --/M      Welsh              cel/cy
 5  da              --/M      Danish             gmq/da
 5  de              --/M      German             gmw/de
 5  el              --/M      Greek              grk/el
 5  en-029          --/M      English_(Caribbean) gmw/en-029           (en 10)
 2  en-gb           --/M      English_(Great_Britain) gmw/en               (en 2)
 5  en-gb-scotland  --/M      English_(Scotland) gmw/en-GB-scotland   (en 4)
 5  en-gb-x-gbclan  --/M      English_(Lancaster) gmw/en-GB-x-gbclan   (en-gb 3)(en 5)
 5  en-gb-x-gbcwmd  --/M      English_(West_Midlands) gmw/en-GB-x-gbcwmd   (en-gb 9)(en 9)
 5  en-gb-x-rp      --/M      English_(Received_Pronunciation) gmw/en-GB-x-rp       (en-gb 4)(en 5)
 2  en-us           --/M      English_(America)  gmw/en-US            (en 3)
 5  eo              --/M      Esperanto          art/eo
 5  es              --/M      Spanish_(Spain)    roa/es
 5  es-419          --/M      Spanish_(Latin_America) roa/es-419           (es-mx 6)(es 6)
 5  et              --/M      Estonian           urj/et
 5  eu              --/M      Basque             eu
 5  fa              --/M      Persian            ira/fa
 5  fa-Latn         --/M      Persian_(Pinglish) ira/fa-Latn
 5  fi              --/M      Finnish            urj/fi
 5  fr-be           --/M      French_(Belgium)   roa/fr-BE            (fr 8)
 5  fr-ch           --/M      French_(Switzerland) roa/fr-CH            (fr 8)
 5  fr-fr           --/M      French_(France)    roa/fr               (fr 5)
 5  ga              --/M      Gaelic_(Irish)     cel/ga
 5  gd              --/M      Gaelic_(Scottish)  cel/gd
 5  gn              --/M      Guarani            sai/gn
 5  grc             --/M      Greek_(Ancient)    grk/grc
 5  gu              --/M      Gujarati           inc/gu
 5  hi              --/M      Hindi              inc/hi
 5  hr              --/M      Croatian           zls/hr               (hbs 5)
 5  hu              --/M      Hungarian          urj/hu
 5  hy              --/M      Armenian_(East_Armenia) ine/hy               (hy-arevela 5)
 5  hy-arevmda      --/M      Armenian_(West_Armenia) ine/hy-arevmda       (hy 8)
 5  ia              --/M      Interlingua        art/ia
 5  id              --/M      Indonesian         poz/id
 5  is              --/M      Icelandic          gmq/is
 5  it              --/M      Italian            roa/it
 5  ja              --/M      Japanese           jpx/ja
 5  jbo             --/M      Lojban             art/jbo
 5  ka              --/M      Georgian           ccs/ka
 5  kl              --/M      Greenlandic        esx/kl
 5  kn              --/M      Kannada            dra/kn
 5  ko              --/M      Korean             ko
 5  kok             --/M      Konkani            inc/kok
 5  ku              --/M      Kurdish            ira/ku
 5  ky              --/M      Kyrgyz             trk/ky
 5  la              --/M      Latin              itc/la
 5  lfn             --/M      Lingua_Franca_Nova art/lfn
 5  lt              --/M      Lithuanian         bat/lt
 5  lv              --/M      Latvian            bat/lv
 5  mi              --/M      poz/mi             poz/mi
 5  mk              --/M      Macedonian         zls/mk
 5  ml              --/M      Malayalam          dra/ml
 5  mr              --/M      Marathi            inc/mr
 5  ms              --/M      Malay              poz/ms
 5  mt              --/M      Maltese            sem/mt
 5  my              --/M      Burmese            sit/my
 5  nb              --/M      Norwegian_Bokmål  gmq/nb               (no 5)
 5  nci             --/M      Nahuatl_(Classical) azc/nci
 5  ne              --/M      Nepali             inc/ne
 5  nl              --/M      Dutch              gmw/nl
 5  om              --/M      Oromo              cus/om
 5  or              --/M      Oriya              inc/or
 5  pa              --/M      Punjabi            inc/pa
 5  pap             --/M      Papiamento         roa/pap
 5  pl              --/M      Polish             zlw/pl
 5  pt              --/M      Portuguese_(Portugal) roa/pt               (pt-pt 5)
 5  pt-br           --/M      Portuguese_(Brazil) roa/pt-BR            (pt 6)
 5  ro              --/M      Romanian           roa/ro
 5  ru              --/M      Russian            zle/ru
 5  sd              --/M      Sindhi             inc/sd
 5  si              --/M      Sinhala            inc/si
 5  sk              --/M      Slovak             zlw/sk
 5  sl              --/M      Slovenian          zls/sl
 5  sq              --/M      Albanian           ine/sq
 5  sr              --/M      Serbian            zls/sr
 5  sv              --/M      Swedish            gmq/sv
 5  sw              --/M      Swahili            bnt/sw
 5  ta              --/M      Tamil              dra/ta
 5  te              --/M      Telugu             dra/te
 5  tn              --/M      Setswana           bnt/tn
 5  tr              --/M      Turkish            trk/tr
 5  tt              --/M      Tatar              trk/tt
 5  ur              --/M      Urdu               inc/ur
 5  vi              --/M      Vietnamese_(Northern) aav/vi
 5  vi-vn-x-central --/M      Vietnamese_(Central) aav/vi-VN-x-central
 5  vi-vn-x-south   --/M      Vietnamese_(Southern) aav/vi-VN-x-south
 5  yue             --/M      Chinese_(Cantonese) sit/yue              (zh-yue 5)(zh 8)

espeak-ng-data 的路徑

ls /usr/share/espeak-ng-data
af_dict   ca_dict  eu_dict   hu_dict      kl_dict   lv_dict    ne_dict            phontab  sr_dict  voices
am_dict   cs_dict  fa_dict   hy_dict      kn_dict   mbrola_ph  nl_dict            pl_dict  sv_dict  zh_dict
an_dict   cy_dict  fi_dict   ia_dict      ko_dict   mi_dict    no_dict            pt_dict  sw_dict  zhy_dict
ar_dict   da_dict  fr_dict   id_dict      kok_dict  mk_dict    om_dict            ro_dict  ta_dict
as_dict   de_dict  ga_dict   intonations  ku_dict   ml_dict    or_dict            ru_dict  te_dict
az_dict   el_dict  gd_dict   is_dict      ky_dict   mr_dict    pa_dict            sd_dict  tn_dict
bg_dict   en_dict  grc_dict  it_dict      la_dict   ms_dict    pap_dict           si_dict  tr_dict
bn_dict   eo_dict  gu_dict   ja_dict      lang      mt_dict    phondata           sk_dict  tt_dict
bpy_dict  es_dict  hi_dict   jbo_dict     lfn_dict  my_dict    phondata-manifest  sl_dict  ur_dict
bs_dict   et_dict  hr_dict   ka_dict      lt_dict   nci_dict   phonindex          sq_dict  vi_dict

從已編譯的 espeak-ng 版本是 1.49.2 版,但安裝後發現該版本不支援中文

# rpm -qa|grep espeak
espeak-ng-1.49.2-4.el8.x86_64

到 github 下載 1.52 版

wget https://github.com/espeak-ng/espeak-ng/archive/refs/tags/1.52.0.tar.gz

直接編譯

ref: questions about mandarin data packet · Issue #1044 · espeak-ng/espeak-ng · GitHub

./autogen.sh
./configure --with-extdict-cmn

這邊最後要看到

        Extended Dictionaries:
            Russian:                   yes
            Chinese (Mandarin):        yes
            Chinese (Cantonese):       yes

編譯

make
make install

測試

espeak-ng -v cmn "english text 你好 more english text" -w test1.wav