CPSLP程序语言 辅导、 写作Python编程设计

” CPSLP程序语言 辅导、 写作Python编程设计CPSLP Programming assignment1 Introduction – Speech SynthesiserYour task for this assignment is to create a speech synthesiser! Your Python program will taketext input from a user and convert it to a sound waveform of intelligible speech. This will be a verybasic waveform Concatenation system, whereby the acoustic units are recordings of diphones.You will be Provided with several files to help you do this:-simpleaudio.pyThis is a version of the simpleaudio.py module that we have used in the lab sessions. TheAudio class contained therein will allow you to save, load and play .wav files as well asperform some simple audio processing functions. You should not modify this file.synth.pyThis is a skeleton structure for your program, with a few hints to get you going. Your task isto fill in the missing components to make it work. You are free to add any classes, methodsor functions that you wish but you must not change the existing argparse arguments.diphones/A folder containing .wav files for the diphone sounds. A diphone is a voice recording lastingfrom the middle of one speech sound to the middle of a second speech sound (i.e. thetransition Between two speech sounds). If you are unfamiliar with diphones, try listening tosome of them to understand what this means. (Hint: you cannot rely upon the fact that allpossible diphones have been given to you!)examples/A folder containing example .wav files to compare how your synthesiser sounds with respectto a reference implementation.2 Task 1 – Basic SynthesisThe primary task for this assignment is to design a program that takes an input phrase and synthesisesit. The main steps in this procedure are as follows:- normalise the text (convert to lower case, remove punctuation, etc.) to give you a straightforwardsequence of words expand the word sequence to a phone (or speech sound) sequence you should makeuse of nltk.corpus.cmudict to do this, which is a pronunciation lexicon provided as partof NLTK. It is already imported in the skeleton script for you, but you will need to find outyourself what the cmudict object is, what it can do and so how to use it for your purposes.Dont forget, utterances should always start and end with a silence phone! For example,saying the sentence Hello! requires a phone sequence of [PAU, HH, AH, L, OW, PAU](where PAU is the label for the short pause or silence phone).1 Expand the phone sequence to the corresponding diphone sequence (e.g. to say Hello!we need [PAU-HH HH-AH AH-L…] etc.) concatenate the necessary diphone wav files together in the right order to produce therequired synthesised audio in an instance of the Audio class. Your aim here is to create asingle new waveform (e.g. one array of audio data in an Audio class instance), and not justto quickly Play one diphone sound after the other, for example.A user should be able to execute your program by running the synth.py script from the commandline with arguments, e.g. the following should play hello:-python synth.py -p helloIf a word is not in the cmudict then your program should take appropriate action (e.g. print aninformative message for the user and exit).You can listen to the examples hello.wav and rose.wav in the ./examples subdirectory, whichwere created as follows:-python synth.py -o hello.wav hello nice to meet youpython synth.py -o rose.wav A rose by any other name would smell as sweetIf you execute the same commands with your program and the output sounds the same then itis likely you have a functioning basic synthesiser! You could also compare waveforms sample bysample, to ensure your synthesiser functions entirely like the reference implementation.3 Task 2 – Extending the FunctionalityImplement at least two of the following extensions:-Extension A Volume Control [easy]Allow the user to set the volume argument (–volume, -v) to a value between 0 and 100(minimum and maximum loudness respectively) to change the amplitude of the synthesisedwaveform.Extension B Spelling [easy]When the user gives the spell command-line argument (–spell, -s) synthesise the textas spelled out instead of read normally. Do this by converting a string into a sequenceof letters, and then to an appropriate phone sequence to pronounce for each letter in itsalphabetic form. At its simplest, you can assume this should only work for single words, butyou can also go further if you wish. [hint: cmudict contains entries for letter names]Extension C Speaking Backwards [fairly easy]Have fun by Making the synthesiser speak backwards in one of three ways:signal When the user gives the commandline option –reverse signal, switch the waveformsignal for the whole synthetic utterance back to front.2words When the user gives the commandline option –reverse words, reverse the orderof the words that will be synthesised (e.g. oh hi there – there hi oh).phones When the user gives the commandline option –reverse phones, reverse the orderof the phones that will be spoken for the whole utterance.Extension D Punctuation [more challenging]If the input phrase contains a comma, insert 200ms of silence. If it contains a period, colon,question mark or exclamation mark, then insert 400ms of silence. Strip and ignore all otherpunctuation. Note, when inserting the silence, you will also have to change the phonesequence to include a PAU phone. For example, if you needed to put a 200ms silencebetween phones … AH HH …, then your sequence of waveform chunks should be …AH-PAU 200ms-silence PAU-HH …. Dont worry about the duration of the PAU segments inyour solution, But do just insert an extra 200 or 400ms of silence in the right places!Finally, to show off your punctuation handling, add code to enable the user to give the–fromfile flag. The user can use this flag to specify a text file containing text to synthesise and in this case, your programme should open the file with the given filename and synthesisewhatever is contained there. Note, however, your programme should process the textsentence by sentence. For example, your programme should synthesise the first sentenceand then play it if the –play flag is given, then synthesise the second, and then play thatone, and so on. If the –outfile option is given by the user, then each of the synthesisedwaveforms must be concatenated to a single waveform prior to saving it at the end.Extension E Emphasis markup [more challenging]One way emphasis can be indicated on a word is by increased loudness, duration and somepitch (f0) accent. Implement a simplified version of this in your synthesiser. Allow the user toput curly braces around any 1 word in the input text, and increase the loudness (dont worryabout duration or pitch) of that word noticeably compared to the rest of the utterance. So,for example:The {cat} sat on the mat.- the word cat should sound louder than the rest of the utterance.Extension F Smoother Concatenation [more challenging]Simply pasting together diphone audio waveforms one after the other can lead to audibleglitches Where the waveform jumps at boundaries between diphones. Implement a simpleway to alleviate this by cross-fading between adjacent diphones using a 10 msec overlap.To achieve a cross-fade, you need to lower the amplitude at the end of one diphone down to0.0 over 10msec and then overlap and add in the signal from the start of the next diphonewhich is similarly tapered from 0.0 to normal amplitude over the same 10msec period. Notethis will only mitigate one cause of choppiness in the synthetic speech and so can only doso much to make it sound better! Audio examples are provided for you to compare crossfadedconcatenation with simple concatenation. Compare sizes of those files with onesproduced by your code. to make sure youre not losing or gaining any samples. [hint: youwill probably find numpy very useful to implement this extension in a succinct and efficientway!]34 Rules and AssessmentYour submission will comprise a single file of Python code and should abide by the following rules:- all submissions must be written individually and be your own work. the Universitys penalties for plagiarism are potentially very harsh. Googling how to use aparticular Python object or syntax feature is to be expected, and finding information in thatway is no problem at all. If you find a one-liner to achieve some neat trick, its also fine toinclude that, as long as you attribute it (e.g. provide the URL for the StackOverflow page youfound it on in a code comment for example). In contrast, cutting and pasting whole sectionsof code, or Even whole functions/classes is definitely not in the spirit of the exercise and willbe penalised. Note, Python code plagiarism detection software can spot copied code evenif the names and formatting are changed. So, please, do just come up with your own code. your submission may only use numpy, nltk, the provided files, and any packages that arebuilt-in to Python. I must be able to run your code on my computer using just the one fileand without installing anything else. you may Not change any of the existing argparse arguments provided in synth.py whenyou view that file you will see argparse has already been set up to take all the correctcommand-line arguments for you.The assignments will be graded out of 100 and will be assessed according to the following criteria:-Task 1Your system:- is able to synthesise several test phrases that contain only words (no punctuation,numbers, etc.). is reasonably robust – for example it can handle out of vocabulary words, or malformedinput, or a missing diphones directory, or even missing diphones, in an elegant and/orinformative way rather than just falling over or breaking is able to play and/or save the output to a fileIMPORTANT: just because your code might run and work as specified above, it does notmean you will necessarily get full marks! Many aspects of your code will be consideredbeyond simply whether it works or not, including for example: has the task clearly been understood with clear evidence of a sensible attempt to implementsolution? does it work entirely as specified? is it efficient? is the code sensible/logical? is the code legible, sufficiently documented and friendly for others is the code robust?4Task 2As a bare minimum, you must implement at least two of the extensions in order to pass.For a higher grade, you can choose to implement more of the extensions, taking care topresent strong solutions. For example, 3 extensions implemented to a high standard couldachieve the Same grade as 4 extensions implemented less well.Also note that the extensions vary in terms of the effort required to implement them. ExtensionA is far simpler than Extension E or F, for example, and the marks awarded willnaturally reflect the intrinsic difficulty of each of the extension tasks. Again, keep in mind thekey marking criteria: functionality, design, legibility, efficiency, and robustness.Style and DesignFurther marks will be awarded based on how well your code is designed and presentedoverall. Therefore, take care to use appropriate object-orientated design as well as suitablecode formatting, naming and plenty of appropriate comments and docstrings. You can alsoearn extra marks by being pythonic (i.e. keeping your code succinct, well-organised andeasily-readable; Good use of nice Python language features (e.g. comprehensions); etc.)You will be required to submit your modified synth.py file once you have finished.Submissions are marked Anonymously. You must prepend your exam number (the B number onyour student card) to the file prior to submitting it, e.g. your submitted file should be in the format:B123456_synth.pyIn addition, do not include Any identifying content (e.g. Matriculation number, name etc.) inthe submitted file. Submit only one Python code file in the above format (and not a zip file forexample).Finally, if you Should have any queries about the task, or questions more generally, then pleasedo not hesitate to ask!如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导