简体   繁体   English

需要连接两个音频数据

[英]Need to concatenate two audio data

I am new to Python.我是 Python 的新手。 Here is my problem, I'm getting input via speech recognizer.这是我的问题,我通过语音识别器获取输入。 The user says code like '1234' and again says '3456'.用户说像“1234”这样的代码,然后又说“3456”。 I'm storing each of the audio data in a variable.我将每个音频数据存储在一个变量中。 I need to concatenate these two.我需要连接这两个。

with sr.Microphone() as source:
    audio = r.listen(source)

 text2 = audio

with sr.Microphone() as source:
    audio = r.listen(source)

text3 = audio

I need to concatenate both the data.我需要连接两个数据。 I have to supply them as the input to a text box.Is there any way to concatenate these data?(text2 and text3) since being an audio.我必须提供它们作为文本框的输入。有没有办法连接这些数据?(text2 和 text3)因为是音频。 I need it in a variable not as an audio file.我需要一个变量而不是音频文件。

The first step in the process is to use a recognizer to turn your AudioData instance into a string.该过程的第一步是使用识别器将您的AudioData实例转换为字符串。 You can do this by:您可以通过以下方式执行此操作:

Creating a recognizer using the same module使用相同的模块创建识别器

r = sr.Recognizer()

Convert the "AudioData" instance to a string using the recognizer使用识别器将“AudioData”实例转换为字符串

some_string1 = r.recognize_sphinx(audio)

Then just do this for say some_string2 , and do some_string1 + some_string2 to concatenate them.然后就这样说some_string2 ,然后做some_string1 + some_string2来连接它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM