<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # python 文字轉語音 > 原文: [https://pythonbasics.org/text-to-speech/](https://pythonbasics.org/text-to-speech/) 文字轉語音(TTS)是將書面文字轉換為語音的方式。您可以使用 python 創建 TTS 程序。 語音的質量取決于您的語音引擎。 在本文中,您將學習如何創建自己的 TTS 程序。 ## python 中的文字轉語音 ### espeak 示例 程序“espeak”是一個簡單的語音合成器,可以將書面文本轉換為語音。 espeak 程序聽起來確實有點機器人化,但是它足夠簡單,可以構建一個基本程序。 ```py import subprocess def execute_unix(inputcommand): p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True) (output, err) = p.communicate() return output a = "Say something in natural language." # create wav file # w = 'espeak -w temp.wav "%s" 2>>/dev/null' % a # execute_unix(w) # tts using espeak c = 'espeak -ven+f3 -k5 -s150 --punct="<characters>" "%s" 2>>/dev/null' % a execute_unix(c) ``` ### TTS 與 Google Google 聽起來很自然。 您可以將其 TTS 引擎與以下代碼一起使用。 對于此程序,您需要安裝模塊 gTTS 以及程序 mpg123。 ```py # need gTTS and mpg123 # pip install gTTS # apt install mpg123 from gtts import gTTS import os # define variables s = "escape with plane" file = "file.mp3" # initialize tts, create mp3 and play tts = gTTS(s, 'en') tts.save(file) os.system("mpg123 " + file) ``` 這將輸出語音/ mp3 文件。 [下載音頻示例](https://social.pythonbasics.org/download-audio-examples/)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看