Because voice recognition requires the use of voxforge speech files, but there are too many voxforge files, manual download is definitely not acceptable. You can use the batch Download Software for download. Out of curiosity, I plan to use python to write a batch download script. Although it can be used at the end, the speed is not good, and it is a single thread. Only one file can be under one file, as a trainer, I tried to download multiple threads after a while.
Therefore, you only need to include href = "********* in the entire source code "********. the tgz section is extracted, and then "href =" "is removed, and the above primary connection is the complete connection of each file.
Well, let's not talk about it much. The source code is as follows, which is not standardized. Let's take a look.
Import urllibimport urllib2import osimport re OS. chdir ('d: \ voxforge speech files \ ', 'W +') # store all download connections mainpath = 'HTTP: // your gettgz (url): page = urllib. urlopen (url) html = page. read () reg = r'href =. *. tgz' tgzre = re. compile (reg) tgzlist = re. findall (tgzre, html) # Find all. tgz file for I in tgzlist: filename = I. replace ('href = ', '') filename = filename. replace ('','') print 'is being downloaded:' + filename # The system prompts downfile = I. replace ('href = ', mainpath) downfile = downfile. replace ('','') # obtain the complete connection req = urllib2.Request (downfile) for each file # download the file ur = urllib2.urlopen (req ). read () open (filename, 'wb '). write (ur) # store the downloaded file in disk D in tgz format # refiles. write (downfile + '') html = gettgz (mainpath) # refiles. close ()
The running effect is as follows: