如何运行 MATLAB 代码以从 PHP 中识别孤立的口语单词? [英] How can I run MATLAB code for isolated spoken words recognition from PHP?

查看:23
本文介绍了如何运行 MATLAB 代码以从 PHP 中识别孤立的口语单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,我有用于孤立口语识别的 MATLAB 代码,我希望能够将此项目与另一个使用 PHP 制作的项目集成在一起目的.

As the title indicates, I have MATLAB code for isolated spoken words recognition, and I want to be able to integrate this project with another one made with PHP for some purpose.

我以前没有处理过这样的问题.换句话说,我是第一次需要整合PHP和MATLAB,所以我真的不知道从哪里开始,如何开始.

I have not used to deal with such problem before. In other words, it's the first time for me when I need to integrate PHP and MATLAB, so I really don't know where to start and how.

我已经阅读了几篇文章,但我无法使其有效.

I have read a couple of articles, but I couldn't make it valid.

我有 PHP 5.4.9、MATLAB R2012A 和 Windows 7.MATLAB 项目文件可以在 在 GitHub 上查看.

I have PHP 5.4.9, MATLAB R2012A and Windows 7. The MATLAB project files can be seen on GitHub.

推荐答案

这里有几个选项:

  • 如果 MATLAB 安装在将部署 PHP 应用程序的服务器上(不是您当前的开发环境),您可以像任何其他程序一样直接调用它(matlab -r "...") 使用 PHP 中与 EXECUTE 等效的命令.以下是一些资源(请务必同时查看链接的问题):

  • If MATLAB installed on the server where the PHP application would be deployed (not your current development environment), you can invoke it directly just like any other program (matlab -r "...") using whatever is the equivalent of EXECUTE command in PHP. Here are some resources (make sure to also checkout the linked questions as well):

其他人评论了如何在 PHP 和您的 MATLAB 脚本之间传递输入/输出.例如,你可以设计你的 MATLAB 函数来接收 WAV 文件的路径作为输入,处理它并将任何结果图像保存到磁盘:

Others have commented on how to pass input/output between PHP and your MATLAB script. For example, you could design your MATLAB function to receive the path of WAV file as input, process it and save any resulting image to disk:

function myFunc(filename)
    [y,Fs] = audioread(filename);
    img = my_process_func(y, FS);
    imwrite(img, 'out.png');
end

从 PHP 调用的:

% Of course you have to make sure "myFunc" is available on the MATLAB path.
% Think: "addpath(..)" or just "cd(..)" into the directory first
matlab -wait -nodisplay -r "myFunc('audio.wav'); quit;"

然后您可以在 PHP 应用程序中读取输出图像.

You could then read the output image in the PHP application.

如果没有,您有哪些与部署相关的工具箱可用?MATLAB Compiler 和相关工具箱,如 MATLAB Builder NEMATLAB建设者 JA.

If not, what deployment-related toolboxes do you have available? MATLAB Compiler and related toolboxes like MATLAB Builder NE and MATLAB Builder JA.

那些将分别将您的程序编译成可执行文件/.NET 程序集/JAR 文件,并且所有这些都需要免费提供的 MCR 运行时 被安装.换句话说,可执行文件不需要在目标机器上安装完整的 MATLAB,只需安装 MCR 运行时即可.

Those will compile your program into an executable/.NET Assembly/JAR file respectively, and all of them require the freely available MCR Runtime to be installed. In other words, the executables do not need to have a full MATLAB installation on the target machine, only the MCR runtime.

您将以与以前相同的方式运行可执行文件.

You would run the executable in the same manner as before.

另一个产品是 MATLAB Coder,它将您的 MATLAB 代码转换为 C++程序.编译后,无需任何外部要求即可运行.

Another product is the MATLAB Coder, which converts your MATLAB code into C++ program. When compiled, it can run without any external requirement.

MathWorks 的新产品是 MATLAB Production Server.我个人对此一无所知:)

A new product by MathWorks is MATLAB Production Server. Personally I know nothing about it :)

另一种选择是使用 TCP/IP 在 PHP 和 MATLAB 之间进行通信.服务器将在 MATLAB 端运行,使用编写为 C MEX 文件或 Java 类的套接字编程.见:

Yet another option is to use TCP/IP to communicate between PHP and MATLAB. A server would be run on the MATLAB side, using socket programming written as C MEX-file or a Java class. See:

客户端是您的 PHP 应用程序.这个想法是让 MATLAB 监听连接,读取客户端给出的任何输入,eval,然后返回结果.这比其他选项更复杂,因为您必须处理序列化和其他诸如并发性之类的事情.优点是 MATLAB 可以在单独的服务器上运行,甚至可以在云上的多台服务器上运行(请参阅这篇文章).

The client being your PHP application. The idea is to have MATLAB listening for connections, reading whatever input is given by a client, eval it, and return the result. This is more involved than the other options, as you have to deal with serialization and other things like concurrency. The advantage is that MATLAB can be run on a separate server, even on multiple servers on the cloud (see this post).

因此,首先,决定哪种方法最适合您的项目,然后回答具体问题会更容易……只要始终先查阅文档,MATLAB 工具箱都有很好的文档记录,通常包含许多示例.以下是更多特定于 MATLAB Compiler 产品系列的资源:

So first, decide what approach best suits your project, then it would be easier to answer specific questions... Just always consult the documentation first, MATLAB toolboxes are very well documented and usually include many examples. Here are a couple more resources specific to MATLAB Compiler products family:

请注意,它们专注于 ASP.NET 和 Java JSP/servlet 应用程序.在您的情况下,PHP 应用程序将与运行使用上述两个选项之一构建的 Web 服务的中间层通信(或者简单地设计一个类似 CGI 的站点,运行使用 MATLAB 编译器构建的普通可执行文件,如前所述).

Note that they concentrate on ASP.NET and Java JSP/servlet applications. In your case, the PHP application would communicate with a middle tier running a web service built using one of the above two options (or simply design a CGI-like site running plain executables built using the MATLAB Compiler as explained earlier).

这篇关于如何运行 MATLAB 代码以从 PHP 中识别孤立的口语单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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