Trying to make a code that tells the weather
5 次查看(过去 30 天)
显示 更早的评论
So I am trying to creat a code(s) that would tell the weather. I would like the code to speak the temperture value. I have the speech code just need to figure out the code for the weather.
0 个评论
回答(2 个)
Image Analyst
2021-9-17
Some of the worlds smartest scientists have been using the worlds largest and fastest super computers for decades trying to do the same thing.
Actually I used to live in San Diego, which has been proven to have the most uniform temperature of any city in the world. Once the newspaper tried to see which of the 3 local TV stations was best at predicting the next day's weather. So they ran the "contest" for 3 months and one of them was most accurate but they said that even that TV station was not as accurate as if they'd just simply said "the weather tomorrow will be exactly the same as today". So if you live in or want to predict weather in San Diego just look up today or yesterday's temperature from the NOAA web site and make that your prediction for tomorrow. I know what it will be : 74 degrees F, because virtually every day of the year is 74 in San Diego. Go ahead and check it.
Once you have that you can use text to speech:
% Program to do text to speech. Works only with Windows Operating System.
% Get user's sentence
userPrompt = 'What do you want the computer to say?';
titleBar = 'Text to Speech';
defaultString = 'Hello World! MATLAB is an awesome program!';
caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
if isempty(caUserInput)
return;
end % Bail out if they clicked Cancel.
caUserInput = char(caUserInput); % Convert from cell to string.
% Instantiate the .NET assembly that will to the talking.
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
% voiceCollection = obj.GetInstalledVoices() % Get list of all voices installed on the system.
% methods(voiceCollection) % See what it can do.
% Set the volume.
obj.Volume = 100;
% Here is the line of code that actually does the talking:
Speak(obj, caUserInput);
%==========================================================================
% Below is the mac version, from Walter Roberson
% userPrompt = 'What do you want the computer to say?';
% titleBar = 'Text to Speech';
% defaultString = 'Hello World! MATLAB is an awesome program!';
% caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
% if isempty(caUserInput)
% return;
% end; % Bail out if they clicked Cancel.
% caUserInput = char(caUserInput); % Convert from cell to string.
%
% system( sprintf('say "%s"', caUserInput) )
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Weather and Atmospheric Science 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!