Hello Mat

 找回密码
 立即注册
查看: 1133|回复: 0

提取语音输出文本唯一出现ID

[复制链接]

11

主题

12

帖子

40

金钱

版主

Rank: 7Rank: 7Rank: 7

积分
80
发表于 2023-7-28 15:49:54 | 显示全部楼层 |阅读模式

【1】采用halcon软件提取语音输出文本唯一出现ID
  1. dev_update_off()
  2. dev_set_draw('margin')
  3. pathwav:='D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/wav/train'
  4. pathtrans := 'D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/transcript'
  5. pathtranscript:='D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/transcript/aishell_transcript_v0.8.txt'
  6. pathtranscriptWords := []
  7. open_file (pathtranscript, 'input', FileHandle)
  8. IsEOF := 0
  9. nums := []
  10. k:=0
  11. while (IsEOF == 0)
  12.     fread_line (FileHandle, Number, IsEOF)
  13.     pathtranscriptWords[k] := Number
  14.     k:=k+1
  15. endwhile
  16. close_file (FileHandle)
  17. *      
  18. * 在pathtranscript里面查找对应的wav对应的输出,找出唯一出现过的字母或者文字
  19. WavNameOutput := ''
  20. for k:=0 to |pathtranscriptWords|-1 by 1
  21.     scriptWord := pathtranscriptWords[k]
  22.     tuple_split(scriptWord, ' ', Substrings2)
  23.     tuple_length(Substrings2, Length1)
  24.     if(Length1>0)
  25.         tuple_split(scriptWord, Substrings2[0], Substrings3)
  26.         tuple_strlen(Substrings3, Length)
  27.         tuple_substr(Substrings3, 1, Length-1, Substring)
  28.         tuple_split(Substring[0], '\n', Substrings)
  29.         WavNameOutput := WavNameOutput + Substrings[0]
  30.     endif
  31. endfor
  32. * WriteTxt (FilePath + WavName + '.txt', WavNameOutput)
  33. * WavInputOut := WavInputOut + WavFile + ',' + FilePath + WavName + '.txt' + '\n'
  34. *
  35. * resPath := 'D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/'
  36. * WriteTxt (resPath + 'ASRInfo.txt', WavInputOut)
  37. UniqueWord := ''
  38. tuple_strlen(WavNameOutput, Length2)
  39. for i:= 0 to Length2-1 by 1
  40.     tuple_substr(WavNameOutput, i, i, CurChar)
  41.     tuple_strchr(UniqueWord, CurChar, Position)
  42.     if(Position==-1 and CurChar != ' ')
  43.         UniqueWord := UniqueWord + CurChar
  44.     endif
  45. endfor
  46. * WriteTxt (FilePath + WavName + '.txt', WavNameOutput)
  47. File_Name := 'D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/LabelWav.json'
  48. file_exists(File_Name,FileExits)
  49. if(FileExits)
  50.     delete_file(File_Name)
  51.     open_file(File_Name,'append',FileHandle)
  52. else
  53.     open_file(File_Name,'output',FileHandle)
  54. endif
  55. fwrite_string(FileHandle, '[' + '\n')
  56. tuple_strlen(UniqueWord, Length3)
  57. for i:= 0 to Length3-1 by 1
  58.     tuple_substr(UniqueWord, i, i, Substring1)
  59.     fwrite_string(FileHandle, '"' + Substring1 + '"' + '\n')
  60. endfor
  61. fwrite_string(FileHandle,  '"' + ' ' + '"'+ '\n')
  62. fwrite_string(FileHandle, ']' + '\n')
  63. close_file (FileHandle)
复制代码
输出如下:
  1. [
  2.   "_",
  3.   "'",
  4.   "a",
  5.   "b",
  6.   "c",
  7.   "d",
  8.   "e",
  9.   "f",
  10.   "g",
  11.   "h",
  12.   "i",
  13.   "j",
  14.   "k",
  15.   "l",
  16.   "m",
  17.   "n",
  18.   "o",
  19.   "p",
  20.   "q",
  21.   "r",
  22.   "s",
  23.   "t",
  24.   "u",
  25.   "v",
  26.   "w",
  27.   "x",
  28.   "y",
  29.   "z",
  30.   " "
  31. ]
复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-10-31 18:23 , Processed in 0.210397 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表