《宏乐语音评分控件》通用版
通用版不受编程工具的限制,所有操作完全不用调用OCX的指令或装载OCX。首先运行“c:\宏乐语音评分控件包\宏乐语音评分通用版.exe”,然后通过对“c:\宏乐语音评分控件包\万能接口参数.bin”的位操作,控制(写)或读取数据。通过“c:\宏乐语音评分控件包\WAV格式声音文件名.ini”可传递WAV文件名。“c:\宏乐语音评分控件包\要对比的特征文件名.ini”可传递特征文件名。
“万能接口参数.bin”是(二进制)格式长度为25字节的文件,结构如下图:
VB6 调试控制程序如下: (该程序源代码附在安装包内)
程序图:
Dim b(1 To 25) As Byte
Dim i As Byte '参数文件的位坐标
Dim a As Byte '控制号
Private Sub Form_Load()
运行_Click
If Dir(App.Path + "\标题名称.ini") <>
"" Then
Open App.Path + "\标题名称.ini" For Input Shared As #1
If EOF(1) = False Then Line Input #1, bak$
Close #1
标题.Text = bak$
End If
If Dir(App.Path + "\万能接口参数.bin")
<> "" Then
'获取高度
Open App.Path + "\万能接口参数.bin" For Binary Shared As #1
Get #1, 18, a
Close #1
高度调节.Value = a
End If
End Sub
Private Sub Form_MouseMove(Button As Integer,
Shift As Integer, X As Single, Y As Single)
Screen.MousePointer = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
关闭_Click
End Sub
Private Sub Picture1_MouseDown(Button As Integer,
Shift As Integer, X As Single, Y As Single)
Call 移动窗体(Button, Shift, X, Y)
End Sub
Private Sub Picture1_MouseMove(Button As Integer,
Shift As Integer, X As Single, Y As Single)
Screen.MousePointer = 5
Call 移动窗体(Button, Shift, X, Y)
End Sub
Private Sub 标题_Change()
Open App.Path + "\标题名称.ini" For Output Shared As #1
Print #1, 标题.Text
Close #1
End Sub
Private Sub 读取结果_Click()
'注意:读取结果要有一个足够的延时时间,否则读取的内容是前一次的结果!
i = 9
Call 读数据
频谱吻合率.Caption = a
i = 10
Call 读数据
频率吻合率.Caption = a
i = 14
Call 读数据
评分.Caption = a
i = 16
Call 读数据
音量.Caption = a
End Sub
Private Sub 对比WAV格式文件_Click()
Open App.Path + "\WAV格式声音文件名.ini" For Output Shared As #1
Print #1, App.Path + "\测试_不翼而飞.wav" '这里是个例子,具体WAV文件名可以从已经保存的库中取其中之一
Close #1
i = 5 '用WAV格式文件来对比(青线)
a = 1
Call 输出数据
End Sub
Private Sub 对比特征文件_Click()
'先确定要对比的特征文件名称
Open App.Path + "\要对比的特征文件名.ini" For Output Shared As #1
Print #1, App.Path + "\录音特征曲线.bin" '这里是个例子,具体特征文件名可以从已经保存的库中取其中之一
Close #1
'控制符
i = 3
a = 1 '对比特征文件
Call 输出数据
End Sub
Private Sub 高度调节_Change()
'控件高度
i = 18
a = 高度调节.Value
Call 输出数据
End Sub
Private Sub 关闭_Click()
i = 2
a = 1
Call 输出数据
End Sub
Private Sub 绘图_Click()
i = 13
If 绘图.Value = 1 Then
a = 1 '允许绘图
Else
a = 2 '禁止绘图
End If
Call 输出数据
End Sub
Private Sub 录音_MouseDown(Button As Integer, Shift
As Integer, X As Single, Y As Single)
i = 15
a = 1 '录音键“按下”
Call 输出数据
End Sub
Private Sub 录音_MouseUp(Button As Integer, Shift
As Integer, X As Single, Y As Single)
i = 15
a = 2 '录音键“放开”
Call 输出数据
End Sub
Private Sub 普通窗_Click()
i = 17
a = 2
Call 输出数据
End Sub
Private Sub 设WAV文件为对比_Click()
Open App.Path + "\WAV格式声音文件名.ini" For Output Shared As #1
Print #1, App.Path + "\测试_不翼而飞.wav" '这里是个例子,具体WAV文件名可以从已经保存的库中取其中之一
Close #1
i = 8 '设置WAV格式声音文件为对比内容(灰线)
a = 1
Call 输出数据
End Sub
Private Sub 设置_Click()
i = 7
a = 1 '设置(将当前的声纹设置为对比内容)〔青线变为灰线〕
Call 输出数据
End Sub
Private Sub 身份鉴别_Click()
i = 6
If 身份鉴别.Value = 1 Then
a = 1 '身份鉴别
Else
a = 2 '取消身份鉴别
End If
Call 输出数据
End Sub
Private Sub 通用接口参数结构表_Click()
结构表.Show
End Sub
Private Sub 悬浮窗_Click()
i = 17
a = 1
Call 输出数据
End Sub
Private Sub 允许F12键_Click()
i = 12
If 允许F12键.Value = 1 Then
a = 1 '允许F12键
Else
a = 2
End If
Call 输出数据
End Sub
Private Sub 运行_Click()
X = Shell(App.Path + "\宏乐语音评分通用版.exe", vbNormalNoFocus)
End Sub
Sub 输出数据()
Open App.Path + "\万能接口参数.bin" For Binary Shared As #1
Put #1, i, a
Close #1
End Sub
Sub 读数据()
Open App.Path + "\万能接口参数.bin" For Binary Shared As #1
Get #1, i, a
Close #1
End Sub
Sub 移动窗体(Button As Integer, Shift As Integer,
X As Single, Y As Single)
If Button = 1 Then
X = Round(X, 0) '取整
Y = Round(Y, 0) '取整
If X < 0 Then X = 0
If Y < 0 Then Y = 0
'分别用两个字节来保存 X轴坐标 与 Y轴坐标 (以像素为单位)
i = 19 '启动移动指令
a = 1
Call 输出数据
i = 20
a = X \ 256 'X高位字节
Call 输出数据
i = 21
a = X Mod 256 'X低位字节
Call 输出数据
i = 22
a = Y \ 256 'X高位字节
Call 输出数据
i = 23
a = Y Mod 256 'X低位字节
Call 输出数据
End If
End Sub
Private Sub 自动录音_Click()
i = 1
If 自动录音.Value = 1 Then
a = 1
Else
a = 2
End If
Call 输出数据
End Sub