语音对讲源码_QQ自动发送语音脚本源码分享

大家好,我是公号3分钟学堂的郭立员!今天这篇文章是:QQ发送语音脚本源码分享

按键精灵本身提供了playsound命令来播放音频文件,但是这个命令有很明显的局限性,作为外放音乐的工具还可以,但是对于我们今天的主题——发送语音就不太好用了,说两点原因啊。

  1. 只能单一的发送语音,如果是模拟器多开就会出现串音的问题。
  2. 通过外发获取音频的,在给app录制,就会有杂音问题。

所以我们选择了另一种方式:替换音频文件。

[En]

So we chose another way: replace the audio file.

先来看看效果如何啊:

从上面的动态画面可以看到,我录制的语音只有3秒,但我发送的语音可以播放10秒以上。很明显,这两个音频是不同的。这是因为在我录制完音频后,我用预先准备好的音频替换了录制的音频10多秒才将其发送出去。

[En]

From the dynamic picture above, we can see that the voice I recorded is only 3 seconds, but the voice I sent can be played for more than 10 seconds. It is obvious that the two are not the same audio. This is because after I finished recording the audio, I replaced the recorded audio with a pre-prepared audio for more than 10 seconds before sending it out.

接下来我以雷电模拟器发送QQ录音为例,来讲解一下具体的操作过程。

首先,找出录制文件的存储位置。

[En]

First, find out where the recording files are stored.

上图是音频文件路径的截图。您可以根据音频的属性找到对应的路径。我会在这里写下路径:

[En]

The above image is a screenshot of the path of the audio file. You can find the corresponding path according to the attributes of the audio. I’ll write down the path here:

/sdcard/tencent/MobileQQ/767894495/ptt/201904/3/

需要注意几点:

①.截图中/storage/emulated/0用/sdcard替换了,这个我不只说过一遍了,还是有很多朋友不知道,其实大多数手机上遇到路径中有/0/,也是这样替换的。

②.767894495是我的测试QQ号,你在使用的时候必须要换成你自己当前操作的QQ号

③.路径中201904/3/是当前的日期,属于动态变化的内容,可以通过获取当前日期得到。

Dim datearr=split(date(),”/”)

Dim yue=datearr(0)&datearr(1)

Dim ri=right(datearr(2),1)

TracePrint yue,ri

下一步是获取音频文件的名称:

[En]

The next step is to get the name of the audio file:

这里使用的山海插件的遍历文件命令,即获取您编写的路径文件夹中的所有文件名,然后选择最新的文件。

[En]

The traversal file command of the Shanhai plug-in used here, that is, get all the file names in the path folder you wrote, and then select the latest file.

Import “shanhai.lua”

dim a=ShanHai.ScanPath(path)

Dim n=UBound(a)

TracePrint a(n)

得到的QQ录音文件是slk后缀的。

其次,脚本的重点是替换音频文件。

[En]

Second, the emphasis of the script is to replace the audio file.

在上一步已经获取到录制文件了,接下来我们用预先准备好的文件替换它。使用到的命令是dir.Copy,关于这个命令的使用方法自己去查看命令介绍,另外自己要发送的文件也是slk格式,不是常见的MP3,一般我是手动用QQ录制一段,格式一样可以直接使用。(源代码中文件路径1就是我准备的音频文件)

这个脚本基本上就是这个内容,唯一的困难可能就是获取最新录制的音频文件路径。

[En]

This script is basically this content, the only difficulty may be to get the latest recorded audio file path.

我会提供下面的源文件,使用时不要盲目抄袭,不同的设备、不同的分辨率不能直接使用,你在使用之前把每一行代码都看清楚了。

[En]

I will provide the source file below, do not copy brainlessly when using, different devices, different resolutions can not be used directly, you read every line of code clearly before you use it.

这里用的是QQ发送录音功能而不是对讲功能,因为录音是生成音频和发送音频分离的,这样我们就可以在发送之前有时间替换文件,这点也非常重要。

源代码分享:

Import “shanhai.lua”

Dim datearr=split(date(),”/”)

Dim yue=datearr(0)&datearr(1)&”/”

Dim ri=right(datearr(2),1)&”/”

TracePrint yue,ri

Dim path=”/sdcard/tencent/MobileQQ/767894495/ptt/”&yue&ri

Dim 文件路径1=”/sdcard/pictures/stream_2019033011330407.slk”

Tap 362, 1069

Delay 3000

Tap 362, 1069

Delay 1000

dim a=ShanHai.ScanPath(path)

Dim n=UBound(a)

TracePrint a(n)

Dim 文件路径2=path&a(n)

Delay 100

TracePrint dir.Copy(文件路径1,文件路径2)

Delay 100

Tap 515,1242

Original: https://blog.csdn.net/weixin_39987926/article/details/111606977
Author: weixin_39987926
Title: 语音对讲源码_QQ自动发送语音脚本源码分享

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/526293/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球