【问题标题】:Is there a way to introduce punctuation into an italian sentence with python?有没有办法用python在意大利语句子中引入标点符号?
【发布时间】:2020-03-16 20:55:13
【问题描述】:

正如标题所示,我需要一个 API 来将标点符号引入意大利语句子中。

我正在使用 SpeechRecognition 将语音转换为文本,但我实现的代码给我输出了没有标点符号的句子。

我的代码如下:

import speech_recognition as sr

recognizer_instance = sr.Recognizer()

with sr.Microphone() as source:
    recognizer_instance.adjust_for_ambient_noise(source)
    print("I'm listening... say something!")
    audio = recognizer_instance.listen(source)
    print("Ok! I'm processing the message!")
try:
    text = recognizer_instance.recognize_google(audio, language="it-IT")
    print("Google understood: \n", text)
except Exception as e:
    print(e)

如果我说,在执行过程中,这句话:

“Mi chiamo Paolo. Tu?”

意思是“我叫保罗。你的?”

输出如下:

我在听……说点什么!
好的!我正在处理消息!
谷歌明白:
mi chiamo Paolo tu

不考虑标点符号。 如何插入这些信息?

谢谢!

【问题讨论】:

    标签: python speech-recognition speech-to-text speech


    【解决方案1】:

    Google Speech Recognition API 支持意大利语的标点符号,但您需要在识别配置中设置enable_automatic_punctuation=True(请参阅here)。将此功能添加到 SpeechRecognition 库的拉取请求是 currently open on GitHub。现在,您可以直接使用 Google API 或尝试添加标点符号作为后处理步骤(这似乎需要付出很多努力,因为它很可能需要训练类似于 Punctuator 的模型)。

    【讨论】:

      猜你喜欢
      • 2021-10-07
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多