Question
I really need help adding voices to my MATLAB code. I am suppose to add voice greeting and announcements to my stuck in the mud
I really need help adding voices to my MATLAB code.
I am suppose to add voice greeting and announcements to my stuck in the mud code.
Stuck in the mud is a popular dice game in UK. The game uses five (5) 6-sided dice to play. The players play in turns.
My stuck in the mud code is:
%% Stuck in the mud n = 5; f = n; roll = 1; mud = []; score = 0; while n > 0 fprintf('ROLL %d ',roll); roll = roll+1; r = randi([1 6],1,n); count2 = sum(r == 2); count5 = sum(r == 5); if (count2 > 0) || (count5 >0) mud = [ mud , repmat(2,1,count2) repmat(5,1,count5)] ; n =n - count2-count5; else score = score+ sum(r); end fprintf('Rolling :');disp(r); fprintf('Stuck in the mud :');disp(mud); fprintf('Game score: %d ',score); fprintf('Number of dice stuck: %d ',size(mud,2)); end
I just need help adding voice and greetings. For example I need to:
Add voice to the game to report the details of the game for the player.
o The following websites can convert any text into voices with downloadable mp3 files.
www.fromtexttospeech.com
www.text2speech.org
o MATLAB can play any WMA, MP3, MPEG-4 AAC, WAV, FLAC audio files. [y,Fs] = audioread('fileName.mp3'); % read sound file sound(y,Fs); % play sound file o Additional sound effects are welcome.
Add voice to greet the player.
Add voice to ask the player to enter the number of rounds to play.
Add voice to announce the current round number (i.e., round 1, round 2, and so on).
Add voice to announce the current turn (i.e. the player is rolling or the computer is rolling). Add voice to announce the current roll number (i.e. roll 1, roll 2, and so on).
Add voice to announce each dice rolled.
Add voice to announce the sum of the score for the current turn after each throw.
Add voice to announce the number of dice stuck after each throw.
After one side played, add voice to announce the current total score for the side. For example, 35 points can be announced as three-five.
After all the rounds are played, add voice to announce the winner or tie.
Add pause as needed between sentences to ensure one sentence is finished before the next sentence starts.
Use at least one user-defined function in the program to reduce code repetition.
The finished program can look like the following example. Extra components are always welcome.
(Play a voice greeting.)
(Play a voice to request the user input.)
Enter the number of rounds to play: 2
ROUND 1!!! (Announce round #1.)
The player starts first: (Announce the players turn.)
ROLL 1 (Announce roll #1.)
Rolling: 5 1 4 5 6 (Announce rolling 5-1-4-5-6.)
Stuck in the mud: 5 5
Game score: 0 (Announce the score: 0)
Number of dice stuck: 2 (Announce the number of dice stuck: 2)
ROLL 2 (Announce roll #2.)
Rolling: 2 2 2 (Announce rolling 2-2-2.)
Stuck in the mud: 5 2 2 5 2
Game score: 0 (Announce the score: 0)
Number of dice stuck: 5 (Announce the number of dice stuck: 5)
The player scores: 0 (Announce the player score: 0)
The Player Total Scored: 0 (Announce the player total score: 0)
The computer goes next: (Announce the computers turn.)
ROLL 1 (Announce roll #1.)
Rolling: 2 4 3 5 4 (Announce rolling 2-4-3-5-4.)
Stuck in the mud: 2 5
Game score: 0 (Announce the score: 0)
Number of dice stuck: 2 (Announce the number of dice stuck: 2)
ROLL 2 (Announce roll #2.)
Rolling: 1 2 4 (Announce rolling 1-2-4.)
Stuck in the mud: 2 2 5
Game score: 0 (Announce the score: 0)
Number of dice stuck: 3 (Announce the number of dice stuck: 3)
ROLL 3 (Announce roll #3.)
Rolling: 4 2 (Announce rolling 4-2.)
Stuck in the mud: 2 2 5 2
Game score: 0 (Announce the score: 0)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 4 (Announce roll #4.)
Rolling: 5 (Announce rolling 5.)
Stuck in the mud: 2 5 2 5 2
Game score: 0 (Announce the score: 0)
Number of dice stuck: 5 (Announce the number of dice stuck: 5)
The computer scores: 0 (Announce the computer score: 0)
The Computer total scored: 0 (Announce the computer total score: 0)
ROUND 2!!! (Announce round #2.)
The player starts first: (Announce the players turn.)
ROLL 1 (Announce roll #1.)
Rolling: 2 4 4 2 5 (Announce rolling 2-4-4-2-5.)
Stuck in the mud: 2 2 5
Game score: 0 (Announce the score: 0)
Number of dice stuck: 3 (Announce the number of dice stuck: 3)
ROLL 2 (Announce roll #2.)
Rolling: 2 2 (Announce rolling 2-2.)
Stuck in the mud: 2 2 2 2 5
Game score: 0 (Announce the score: 0)
Number of dice stuck: 5 (Announce the number of dice stuck: 5)
The player scores: 0 (Announce the player score: 0)
The Player Total Scored: 0 (Announce the computer score: 0)
The computer goes next: (Announce the computers turn.)
ROLL 1 (Announce roll #1.)
Rolling: 4 4 1 1 1 (Announce rolling 4-4-1-1-1.)
Stuck in the mud:
Game score: 11 (Announce the score: 1-1)
Number of dice stuck: 0 (Announce the number of dice stuck: 0)
ROLL 2 (Announce roll #2.)
Rolling: 1 4 5 6 4 (Announce rolling 1-4-5-6-4.)
Stuck in the mud: 5
Game score: 11 (Announce the score: 1-1)
Number of dice stuck: 1 (Announce the number of dice stuck: 1)
ROLL 3 (Announce roll #3.)
Rolling: 6 5 1 1 (Announce rolling 6-5-1-1.)
Stuck in the mud: 5 5
Game score: 11 (Announce the score: 1-1)
Number of dice stuck: 2 (Announce the number of dice stuck: 2)
ROLL 4 (Announce roll #4.)
Rolling: 2 5 1 (Announce rolling 2-5-1.)
Stuck in the mud: 2 5 5 5
Game score: 11 (Announce the score: 1-1)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 5 (Announce roll #5.)
Rolling: 5 (Announce rolling 5.) Stuck in the mud: 2 5 5 5 5
Game score: 11 (Announce the score: 1-1)
Number of dice stuck: 5 (Announce the number of dice stuck: 5)
The computer scores: 11 (Announce the computer score: 1-1)
The Computer total scored: 11 (Announce the computer total score: 1-1)
The computer wins! (Announce the computer wins.)
>>
The program should end when the player wants to play 0 round.
(Play a voice greeting.)
(Play a voice to request the user input.)
Enter the number of rounds to play: 0
The game ends with a tie (Announce the game ends in a tie.)
The program should be able to handle a negative input.
(Play a voice greeting.)
(Play a voice to request the user input.)
Enter the number of rounds to play: -1
The game ends with a tie (Announce the game ends with a tie.)
>>
The program should be able to handle a floating point input without crashing.
(The following example takes the floor value of 1.2 and only runs 1 round. )
(Play a voice greeting.)
(Play a voice to request the user input.)
Enter the number of rounds to play: 1.2
ROUND 1!!! (Announce round #1.)
The player starts first: (Announce the players turn.)
ROLL 1 (Announce roll #1.)
Rolling: 3 6 2 2 6 (Announce rolling 3-6-2-2-6.)
Stuck in the mud: 2 2 Game score: 0 (Announce the score: 0)
Number of dice stuck: 2 (Announce the number of dice stuck: 0)
ROLL 2 (Announce roll #2.)
Rolling: 4 4 4 (Announce rolling 4-4-4.)
Stuck in the mud: 2 2
Game score: 12 (Announce the score: 1-2)
Number of dice stuck: 2 (Announce the number of dice stuck: 2)
ROLL 3 (Announce roll #3.)
Rolling: 3 1 5 (Announce rolling 3-1-5.)
Stuck in the mud: 2 2 5
Game score: 12 (Announce the score: 1-2)
Number of dice stuck: 3 (Announce the number of dice stuck: 3)
ROLL 4 (Announce roll #4.)
Rolling: 6 5 (Announce rolling 6-5.)
Stuck in the mud: 5 2 2 5
Game score: 12 (Announce the score: 1-2)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 5 (Announce roll #5.)
Rolling: 1 (Announce rolling 1.)
Stuck in the mud: 5 2 2 5
Game score: 13 (Announce the score: 1-3)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 6 (Announce roll #6.)
Rolling: 1 (Announce rolling 1.)
Stuck in the mud: 5 2 2 5
Game score: 14 (Announce the score: 1-4)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 7 (Announce roll #7)
Rolling: 5 (Announce rolling 5.)
Stuck in the mud: 5 5 2 2 5
Game score: 14 (Announce the score: 1-4)
Number of dice stuck: 5 (Announce the number of dice stuck: 5)
The player scores: 14 (Announce the player score: 1-4)
The Player Total Scored: 14 (Announce the player total score: 1-4)
The computer goes next: (Announce the computers turn.)
ROLL 1 (Announce roll #1.)
Rolling: 6 5 6 4 2 (Announce rolling 6-5-6-4-2.)
Stuck in the mud: 5 2
Game score: 0 (Announce the score: 0)
Number of dice stuck: 2 (Announce the number of dice stuck: 2)
ROLL 2 (Announce roll #2.)
Rolling: 2 4 5 (Announce rolling 2-4-5.)
Stuck in the mud: 2 5 5 2
Game score: 0 (Announce the score: 0)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 3 (Announce roll #3.)
Rolling: 4 (Announce rolling 4.
Stuck in the mud: 2 5 5 2
Game score: 4 (Announce the score: 4)
Number of dice stuck: 4 (Announce the number of dice stuck: 4)
ROLL 4 (Announce roll #4.)
Rolling: 2 (Announce rolling 2.)
Stuck in the mud: 2 5 2 5 2
Game score: 4 (Announce the score: 4)
Number of dice stuck: 5 (Announce the number of dice stuck: 5)
The computer scores: 4 (Announce the computer score: 4)
The Computer total scored: 4 (Announce the computer total score: 4)
The player wins! (Announce the player wins.)
Thank you so much
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started