Hello Mat

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

提取AISHELL-1输入输出

[复制链接]

11

主题

12

帖子

40

金钱

版主

Rank: 7Rank: 7Rank: 7

积分
80
发表于 2023-7-28 15:51:16 | 显示全部楼层 |阅读模式
提取AISHELL-1输入输出
【1】采用halcon进行提取
  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. WavInputOut := ''
  19. list_files(pathwav, 'directories', Files)
  20. for i:= 0 to |Files|-1 by 1
  21.     FilePath:=Files[i]
  22.     list_image_files(FilePath, 'wav', [], WavFiles)
  23.     for j:= 0 to |WavFiles|-1 by 1
  24.         WavFile := WavFiles[j]
  25.         tuple_split(WavFile, '/', Substrings)
  26.         WavNameExt := Substrings[|Substrings|-1]
  27.         tuple_split(WavNameExt, '.wav', Substrings1)
  28.         WavName:= Substrings1[0]
  29.         * 在pathtranscript里面查找对应的wav对应的输出
  30.         WavNameOutput := ''
  31.         for k:=0 to |pathtranscriptWords|-1 by 1
  32.             scriptWord := pathtranscriptWords[k]
  33.             tuple_split(scriptWord, ' ', Substrings2)
  34.             tuple_length(Substrings2, Length1)
  35.             if(Length1>0)
  36.                 if(Substrings2[0]==WavName)
  37.                     tuple_split(scriptWord, WavName, Substrings3)
  38.                     tuple_strlen(Substrings3, Length)
  39.                     tuple_substr(Substrings3, 1, Length-1, Substring)
  40.                     WavNameOutput := Substring
  41.                     break
  42.                 endif
  43.             endif
  44.         endfor
  45.         WriteTxt (FilePath + WavName + '.txt', WavNameOutput)
  46.         WavInputOut := WavInputOut + WavFile + ',' + FilePath + WavName + '.txt' + '\n'
  47.     endfor
  48. endfor
  49. *
  50. resPath := 'D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/'
  51. WriteTxt (resPath + 'ASRInfo.txt', WavInputOut)
复制代码
写txt
  1. file_exists(File_Name,FileExits)
  2. if(FileExits)
  3.     delete_file(File_Name)
  4.     open_file(File_Name,'append',FileHandle)
  5. else
  6.     open_file(File_Name,'output',FileHandle)
  7. endif
  8. fwrite_string(FileHandle, outputstr + '\n')
  9. close_file (FileHandle)
  10. return ()
复制代码

得到结果如下:

  1. D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0122.wav,D:\2-LearningCode\902-ASR\AISHELL-1\data_aishell\wav\train\S0002\BAC009S0002W0122.txt
  2. D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0123.wav,D:\2-LearningCode\902-ASR\AISHELL-1\data_aishell\wav\train\S0002\BAC009S0002W0123.txt
  3. D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0124.wav,D:\2-LearningCode\902-ASR\AISHELL-1\data_aishell\wav\train\S0002\BAC009S0002W0124.txt
  4. D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0125.wav,D:\2-LearningCode\902-ASR\AISHELL-1\data_aishell\wav\train\S0002\BAC009S0002W0125.txt
  5. D:/2-LearningCode/902-ASR/AISHELL-1/data_aishell/wav/train/S0002/BAC009S0002W0126.wav,D:\2-LearningCode\902-ASR\AISHELL-1\data_aishell\wav\train\S0002\BAC009S0002W0126.txt
复制代码








回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-22 11:57 , Processed in 0.210045 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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