


Directly call the WeChat applet recording interface, and then upload it to the server. Baidu Voice’s interface cannot recognize files in this format, so the question is
1. How to transcode? ffmpeg?
2. How to use it in PHP?
This article will solve these two problems.
Third-party tools used:
1. Baidu Voice
2. Silk file format conversion
1. Transcoding silk files Format
The portal is here: github.com/kn007/silk-v3-decoder
It should be noted that:
1. First, install - ffmpeg , please refer to Baidu for the specific installation method. If you want to transcode to MP3 format, please remember to enable libmp3lame, that is, --enable-libmp3lame
2. If you are using silk -v3-decoder prompts that the transcoding failed during the process. Please add ffmpeg to the environment variables or modify converter.sh as shown below. The latter is recommended because executing shell scripts through PHP does not read environment variables
2. How to use it in PHP
With the above artifact, mom no longer has to worry about speech recognition problems.
Currently, thinkPHP 5 is used as the server system, and audio files are uploaded to the background on the applet side. TP5 already has a file upload function package, and the specific upload code will not be detailed;
We only need to read the uploaded file, transcode it through the shell command, and then send the transcoded file to the Baidu voice interface to get the speech recognition result.
You need to pay attention to the following points:
1. The code for php to perform transcoding is as follows
$real_file is The absolute address of the transcoded audio file is recommended to be converted into WAV format. The amr format conversion was unsuccessful and the reason is unknown.
2. Call Baidu Voice Interface Format Settings
You need to set the audio format to WAV, with a code rate of 16000 or 8000, as shown in the figure:
3. Summary
The voice interface of the mini program is different from the voice interface of the official account. The voice interface of the official account returns the amr format, while the mini program returns silk. format is a network audio format open sourced by Skype. It can be transcoded through the tools in the portal. The transcoding tool first converts it into a pcm format file, and then converts it into a specified format. In fact, Baidu Voice can already recognize the pcm format. If you need it, you can modify the converter.sh script.
【Related recommendations】
1. Complete source code download of WeChat mini program
2. WeChat mini program game demo choose different colors Block
3. WeChat applet demo: carousel image transformation
The above is the detailed content of Example of voice search (SUSE version) for mini program development. For more information, please follow other related articles on the PHP Chinese website!

如何在uni-app中实现小程序开发和发布随着移动互联网的发展,小程序成为了移动应用开发的一个重要方向。而uni-app作为一个跨平台的开发框架,可以同时支持多个小程序平台的开发,如微信、支付宝、百度等。下面将详细介绍如何使用uni-app开发和发布小程序,并提供一些具体的代码示例。一、小程序开发前准备在开始使用uni-app开发小程序之前,需要做一些准备工

PHP在小程序开发中的页面跳转与路由管理随着小程序的快速发展,越来越多的开发者开始将PHP与小程序开发相结合。在小程序开发中,页面跳转和路由管理是非常重要的一部分,它能够帮助开发者实现页面之间的切换和导航操作。PHP作为一种常用的服务器端编程语言,可以很好地与小程序进行交互和数据传递,下面我们来详细了解一下PHP在小程序中的页面跳转与路由管理。一、页面跳转基

小程序开发中的PHP权限管理与用户角色设定随着小程序的普及和应用范围的扩大,用户对于小程序的功能和安全性提出了更高的要求,其中权限管理和用户角色设定是保证小程序安全性的重要一环。在小程序中使用PHP进行权限管理和用户角色设定能够有效地保护用户的数据和隐私,下面将介绍如何实现这一功能。一、权限管理的实现权限管理是指根据用户的身份和角色,授予不同的操作权限。在小

小程序开发中的PHP数据缓存与缓存策略随着小程序的快速发展,更多的开发者开始关注如何提高小程序的性能和响应速度。其中一个重要的优化手段就是使用数据缓存来减少对数据库和外部接口的频繁访问。而在PHP中,我们可以利用各种缓存策略来实现数据缓存。本文将介绍PHP中的数据缓存原理,并提供几个常见的缓存策略的示例代码。一、数据缓存原理数据缓存是指将数据存放在内存中,以

小程序开发中的PHP安全防护与攻击防范随着移动互联网的迅猛发展,小程序成为了人们生活中重要的一部分。而PHP作为一种强大而灵活的后端开发语言,也被广泛应用于小程序的开发中。然而,安全问题一直是程序开发中需要重视的方面。本文将重点介绍小程序开发中PHP的安全防护与攻击防范,同时提供一些代码示例。XSS(跨站脚本攻击)防范XSS攻击是指黑客通过向网页注入恶意脚本

今天我们来学习一下微信小程序中PHP开发的下拉菜单实现方法。微信小程序是一种轻量级的应用程序,用户可以在微信里直接使用,而且不需要下载安装,非常方便。而PHP是一种非常流行的后端编程语言,也是与微信小程序配合很好的一种语言。下面我们就来看看如何在微信小程序中使用PHP开发下拉菜单。首先,我们需要准备好开发环境,包括PHP、微信小程序开发工具和服务器。然后我们

小程序开发中的PHP页面动画效果与交互设计导语:小程序是一种在移动设备上运行的应用程序,能够提供类似原生应用的体验。而在小程序开发中,PHP作为一种常用的后端语言,可以为小程序页面增添动画效果与交互设计。本文将介绍一些常用的PHP页面动画效果与交互设计,并附上代码示例。一、CSS3动画CSS3提供了丰富的属性和方法,用于实现各种动画效果。而在小

UC浏览器如何使用语音搜索?UC浏览器是一款有着非常良好的上网搜索服务的浏览器软件,能够为用户们提供非常智能化的在线搜索服务。在UC浏览器之中,各位可以通过文字,图片,甚至语音进行搜索,其中的语音搜索功能非常好用,可以帮助我们快速而又方便的找到一切需要的网络资源。各位如果也想尝试一下的话,就随小编一起来看看语音搜索功能使用方法介绍吧。UC浏览器如何使用语音搜索1、在uc浏览器我的页面点击【设置】选项。2、进入到更多设置页面后,点击【高级设置】选项。3、在高级设置页面开启【快速进入语音搜索】功能即


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
