如何在语音到文本应用程序中使用多线程来显示帧中的文本? [英] How use multithreading in speech to text application to display text in frames?

查看:110
本文介绍了如何在语音到文本应用程序中使用多线程来显示帧中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我有将完整的音频文件转换为文本的代码,我希望通过多线程逐行转换。

actually i have code which convert complete audio file into text and i want to convert line by line through multi threading.

推荐答案

Errm,不,你不。你可能认为你这样做了,但实际上你需要定义的是多线程你的意思。



这是一个具有挑衅性的开头段落,但它很重要你要意识到你需要在应用程序的上下文中围绕多线程意味着什么。如果您只是在谈论将音频转换为文本而不是在UI线程上运行,那么您只需要在后台任务中运行整个过程。这是相当简单的(我会使用任务并行库)。
Errm, no you don't. You may think you do, but in reality what you need to define is what you mean by multi-threading.

That was a provocative opening paragraph, but it's important for you to realise that you need to put bounds around what multi-threading means in the context of the application. If you are just talking about converting the audio into text and not having it run on a UI thread, then you would simply want to run the entirety of the process in a background task. This is fairly straightforward (I would do this using the Task Parallel Library).
Task.Factory.StartNew(()=> ConvertAudioFile());

但是,如果你在谈论在一个单独的线程上转换每一行,那么我会提醒你不要这样做,原因如下:



1.你怎么知道音频文件中的一行已经完成?

你必须处理一行来知道它是一行。那么,通过将它放在一个线程上你会得到什么?



2.如果没有复杂的同步,你不能保证按照你的顺序排列他们在。这就是线程的重点 - 它不是确定性的。

If, however, you are talking about converting each line on a separate thread, then I would caution you against this for the following reasons:

1. How do you know when a line has finished in an audio file?
You would have to process a line to know that it was a line. So, what would you gain by putting it on a thread?

2. Without complex synchronisation, you aren't guaranteed to get the lines out in the order you put them in. That's kind of the point with threading - it's not deterministic.


这篇关于如何在语音到文本应用程序中使用多线程来显示帧中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆