matlab创建成绩单
Legend has it that several years ago the inhabitants of the earth all spoke one language. They all communicated easily and there was peace in the land. Suddenly, they came together to build a tower to speak face-to-face with their maker. Their maker laughed hysterically and simply did one thing––disrupted their language. These inhabitants started speaking in many different languages, they couldn’t understand each other. Confusion was spread like fire over the face of the earth. And the plan and tower had to be abandoned. What a shame!
传说几年前地球上的居民都讲一种语言。 他们都很轻松地进行了交流,这片土地上充满了和平。 突然,他们聚在一起建造一座塔楼,与制造商面对面交谈。 他们的创造者歇斯底里地大笑,只做了一件事-扰乱了他们的语言。 这些居民开始用多种不同的语言说话,他们彼此之间听不懂。 混乱像大火一样散布在大地上。 并且计划和塔必须被放弃。 多可惜!
Wait a minute. What if there was a way for these earthly beings to record their conversations and have it translated for other people to understand? What if they had the ability to create transcripts for their videos? Perhaps, the mighty edifice would have been completed successfully. In this article, I’ll show how to create transcripts for your videos using Cloudinary. Check out the repo to get the code.
等一下。 如果这些世俗的人有办法记录他们的谈话并将其翻译为其他人理解,该怎么办? 如果他们有能力为自己的视频创建字幕,该怎么办? 也许,这座宏伟的大厦将成功完成。 在本文中,我将展示如何使用Cloudinary为您的视频创建字幕。 查看仓库以获取代码。
什么是Cloudinary? ( What’s Cloudinary? )
Cloudinary is a cloud-based, end-to-end media management solution. As a critical part of the developer stack, Cloudinary automates and streamlines your entire media asset workflow. It handles a variety of media, from images, video, audio to emerging media types. It also automates every stage of the media management lifecycle, including media selection, upload, analysis and administration, manipulation optimization and delivery.
Cloudinary是基于云的端到端媒体管理解决方案。 作为开发人员堆栈的关键部分,Cloudinary可以自动化并简化整个媒体资产工作流程。 它处理各种媒体,从图像,视频,音频到新兴媒体类型。 它还可以自动执行媒体管理生命周期的每个阶段,包括媒体选择,上载,分析和管理,操作优化和交付。
上载影片 ( Uploading Videos )
Uploading videos with Cloudinary is as simple as using the upload widget
![Cloudinary Upload Widget](https://i-blog.csdnimg.cn/blog_migrate/1bccec3cd3e72f2877bf9c2ef818fa76.png)
Cloudinary上传小部件
Performing server-side uploads is also as simple as:
执行服务器端上传也很简单:
cloudinary.v2.uploader.upload("dog.mp4",
{ resource_type: "video" },
function(result) {console.log(result); });
为视频创建字幕 ( Creating a Transcript For Videos )
Cloudinary has a new add-on offering support for video transcription using Google speech. Quickly create a new account with Cloudinary if you don’t have any.
Cloudinary有一个新的附加组件,它支持使用Google语音的视频转录。 如果没有,请使用Cloudinary快速创建一个新帐户 。
第1步 (Step 1)
Subscribe to the Google speech internal add-on plan. Currently, transcription only supports English audio. And 1 add-on unit is equivalent to 15 video seconds.
订阅Google语音内部附加计划。 当前,转录仅支持英语音频。 1个附加单元等于15个视频秒。
第2步 (Step 2)
Set up a Node server. Initialize a package.json
file:
设置节点服务器。 初始化package.json
文件:
npm init
Install the following modules:
安装以下模块:
npm install express multer cloudinary cors body-parser --save
express: We need this module for our API routes multer: Needed for parsing http requests with content-type multipart/form-data cloudinary: Node SDK for Cloudinary body-parser: Needed for attaching the request body on express’s req object cors: Needed for enabling CORS
express:我们需要此模块来实现API路由更新:使用内容类型multipart / form-data解析HTTP请求时需要cloudinary: Cloudinary的 Node SDK 正文解析器:需要将请求正文附加到express的req对象上:需要启用CORS
第三步 (Step 3)
Create a server.js file in your root directory. Require the dependencies we installed:
在您的根目录中创建一个server.js文件。 需要我们安装的依赖项:
const express = require('express');
const app = express();
const cloudinary = require('cloudinary');
const cors = require('cors');
const bodyParser = require('body-parser');
const multer = require('multer');
const multerMiddleware = multer({ dest: 'video/' });
// increase upload limit to 50mb
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true, parameterLimit:50000}));
app.use(cors());
cloudinary.config({
cloud_name: 'xxxxxxxxxxx',
api_key: 'xxxxxxxxxxx',
api_secret: 'xxxxxxxxxxxxx'
});
app.post('/upload', multerMiddleware.single('video'), function(req, res) {
console.log("Request", req.file.path);
// Upload to Cloudinary
cloudinary.v2.uploader.upload(req.file.path,
{
raw_convert: "google_speech",
resource_type: "video",
notification_url: 'https://requestb.in/wh7fktwh'
},
function(error, result) {
if(error) {
console.log("Error ", error);
res.json({ error: error });
} else {
console.log("Result ", result);
res.json({ result: result });
}
});
});
app.listen(3333);
console.log('Listening on localhost:3333');
Make sure your server is running:
确保您的服务器正在运行:
nodemon server.js
Once a user makes a POST request to the /upload
route, the route grabs the video file from the HTTP request, uploads to Cloudinary, and makes a request to Google Speech to extract the text from the voice in the video recording.
用户向/upload
路由发出POST请求后,该路由会从HTTP请求中获取视频文件,然后上传到Cloudinary,然后向Google Speech请求,以从视频录制中的语音中提取文本。
The notification_url is an HTTP URL to notify your application (a webhook) when the file has completed uploading. In this code demo, I set up a webhook quickly with the ever-efficient requestbin.
notification_url是一个HTTP URL,用于在文件完成上传后通知您的应用程序(一个Webhook)。 在此代码演示中,我使用高效的requestbin快速设置了一个Webhook 。
Immediately the video is done uploading, a notification is sent to the webhook.
视频立即上传完成,通知发送到网络挂钩。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/media/21401/TQjoHeynTzC3KcFZVE9M_image3.png)
Inspecting the response sent from Cloudinary to the Webhook
检查从Cloudinary发送到Webhook的响应
In the image above, you can see the response states that the transcript creation status is pending. Check out the full response.
在上图中,您可以看到响应状态,表示脚本创建状态为“ 待定” 。 查看完整答复。
"info": {
"raw_convert": {
"google_speech": {
"status": "pending"
}
}
},
Extract from the full response
从完整回复中摘录
Another notification is sent to the webhook once the transcript has been fully extracted from the video recording.
一旦从录像中完全提取了记录,便会向网络挂钩发送另一个通知。
![](https://i-blog.csdnimg.cn/blog_migrate/f7a2e52cf061061460f30497fc60f543.png)
Inspecting the response sent from Cloudinary to the Webhook
检查从Cloudinary发送到Webhook的响应
Check out the full response below:
查看下面的完整回复:
{
"info_kind": "google_speech",
"info_status": "complete",
"public_id": "tb5lrftmeurqfmhqvf6h",
"uploaded_at": "2017-11-23T15:06:55Z",
"version": 1511449614,
"url": "http://res.cloudinary.com/unicodeveloper/video/upload/v1511449614/tb5lrftmeurqfmhqvf6h.mov",
"secure_url": "https://res.cloudinary.com/unicodeveloper/video/upload/v1511449614/tb5lrftmeurqfmhqvf6h.mov",
"etag": "47d8aad801c4d7464ddf601f71ebddc7",
"notification_type": "info"
}
Now, the transcript has been created. Next, attach it to the l_subtitles
transformation property.
现在,记录已创建。 接下来,将其附加到l_subtitles
转换属性。
第4步 (Step 4)
The transcript was created in step 3. It’s very important that you know that the transcript value is {public_id}.transcript
. This is what I mean––the public_id
of the video I uploaded is tb5lrftmeurqfmhqvf6h
. Therefore, the transcript will be tb5lrftmeurqfmhqvf6h.transcript
.
笔录是在步骤3中创建的。非常重要的一点是,您知道笔录值为{public_id}.transcript
。 这就是我的意思–我上传的视频的public_id
是tb5lrftmeurqfmhqvf6h
。 因此,成绩单将为tb5lrftmeurqfmhqvf6h.transcript
。
All you need to do now is add it as an overlay to the video URL with the l_subtitles
parameter like so:
现在您需要做的就是使用l_subtitles
参数将其作为视频URL的叠加层添加,如下所示:
l_subtitles:tb5lrftmeurqfmhqvf6h.transcript
Finally, the URL of the video with the transcript enabled will be:
最后,启用了字幕的视频的网址为:
https://res.cloudinary.com/unicodeveloper/video/upload/l_subtitles:tb5lrftmeurqfmhqvf6h.transcript/v1511449614/tb5lrftmeurqfmhqvf6h.mp4
Video without transcript
没有字幕的视频
Video with transcript enabled
启用了字幕的视频
Note: Cloudinary now supports converting video audio from stereo to mono using the fl_mono transformation.
注意: Cloudinary现在支持使用fl_mono 转换将视频音频从立体声转换为单声道。
Check this out:
看一下这个:
Here, we used the Cloudinary Node.js library. The raw_convert
parameter also works with other SDKs––PHP, Ruby, Java, etc
在这里,我们使用了Cloudinary Node.js库 。 raw_convert
参数还可以与其他SDK(PHP,Ruby,Java等)一起使用
字幕样式 ( Styling Subtitles )
Subtitles are displayed using the default white color and centered alignment. You can use transformation parameters to adjust the color, font, font size, and position. For example, let’s change the color of our example subtitle to green. I’ll also change its alignment.
字幕使用默认的白色和居中对齐显示。 您可以使用转换参数来调整颜色,字体,字体大小和位置。 例如,让我们将示例字幕的颜色更改为绿色。 我还将更改其对齐方式。
Transformation––change color to green, change position to south_west. cogreen_, gsouth_west_
转换–将颜色更改为绿色,将位置更改为south_west。 co green_, g south_west_
结论 ( Conclusion )
The inhabitants of the earth now have a solution to their initial problem. You are the godsent programmer, problem solver and solution architect. Go, create transcripts for your videos. Programmatically creating video transcripts and applying them to the videos has never been this easy. Check out Cloudinary’s video solution for more insights on automating your video management workflow.
现在地球上的居民可以解决他们最初的问题。 您是天赐的程序员,问题解决者和解决方案架构师。 开始,为您的视频创建成绩单。 以编程方式创建视频成绩单并将其应用于视频从未如此简单。 查看Cloudinary的视频解决方案,以获取有关自动化视频管理工作流程的更多见解。
Worthy of note is that 1 add-on unit is equivalent to 15 seconds. If you need more, contact the Cloudinary support team.
值得注意的是1个附加单元等于15秒 。 如果您需要更多,请联系Cloudinary支持团队 。
翻译自: https://scotch.io/tutorials/creating-transcript-for-videos
matlab创建成绩单