我们可以复制别人的声音并在 python 中用作说话功能吗?

can we copy someone else vocals and use as speak function in python?

嘿,我想知道

import pyttsx3

engine = pyttsx3.init('sapi5')

voices= engine.getProperty('voices') #getting details of current voice

engine.setProperty('voice', voice[0].id)
def speak(audio):

engine.say(audio) 

engine.runAndWait()

在这段代码中engine.setProperty('voice', voice[0].id)这一行为我们设置了音频所以可以使用我们自己的音频?来自剪辑或类似的东西?

好吧,让我们看看文档:

Supported synthesizers

Version 2.6 of pyttsx3 includes drivers for the following text-to-speech synthesizers. Only operating systems on which a driver is tested and known to work are listed. The drivers may work on other systems.

SAPI5 on Windows XP and Windows Vista and Windows 8,8.1 , 10 NSSpeechSynthesizer on Mac OS X 10.5 (Leopard) and 10.6 (Snow Leopard) espeak on Ubuntu Desktop Edition 8.10 (Intrepid), 9.04 (Jaunty), and 9.10 (Karmic)

The pyttsx3.init() documentation explains how to select a specific synthesizer by name as well as the default for each platform.

这里:

engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
  engine.setProperty('voice', voice.id)
  engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

所以答案是,不,很遗憾,您不能使用自己的音频。语音合成器是复杂的程序,一个声音是由很多很多的样本创建的,你不能只根据一个录音创建一个新的声音。

Pyttsx3 是一个框架,一个 python 包装器,它改编了 3 个已经存在的语音合成器以用于 Python。 getProperty('voices') 的作用是为您提供先前选择的合成器支持的语音列表(例如亚美尼亚语或女性英国英语等)。

您可以 打印 列表以更好地了解您选择的引擎支持哪些声音。