jhudsl / mscstts

R Client for the Microsoft Cognitive Services Text to Speech REST API
GNU General Public License v3.0
8 stars 6 forks source link

changed URLs #2

Closed AndreMikulec closed 5 years ago

AndreMikulec commented 6 years ago

John Muschelli,

I am not using the github version ( I am using the one from CRAN )

I notice the the word 'bing' is still in here ( in development ). https://github.com/muschellij2/mscstts/blob/master/R/ms_synthesize.R

I ordered the 7 day trial of Azure. Today is day 1. They explained that the 7 day trial is 'hardcoded' to west. I had to make two changes to get it (english text to speech) to work.

"Endpoint" was sent to me by email

fix("get_ms_tts_token")

  # CHANGE 1  
  # text to speech
  # token_url =        paste0('https://api.cognitive.microsoft.com/', 'sts/v1.0/issueToken')
  token_url   = paste0('https://westus.api.cognitive.microsoft.com/', 'sts/v1.0/issueToken')

Speech service REST APIs 05/08/2018 https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-apis

fix("ms_synthesize")

  # CHANGE #2
  # text to speech
  # synth_url = paste0('https://speech.platform.bing.com/','synthesize')
  synth_url = paste0('https://westus.tts.speech.microsoft.com/cognitiveservices/v1')

I do notice the mass amount of work done by you during the last few months. That is awesome. Thanks for the R package.

muschellij2 commented 6 years ago

I no longer have access to the API keys. Can you try the new mscstts version I just pushed

devtools::install_github("muschellij2/mscstts")

and confirm the fix?

revodavid commented 6 years ago

The endpoint should indeed be https://api.cognitive.microsoft.com/sts/v1.0. The above link is for the Speech to Text API; the docs for Text to Speech and the URL in the Azure portal indicate the correct URL.

muschellij2 commented 6 years ago

Got it - will revert.

muschellij2 commented 6 years ago

I have reverted, but I think that was pre-emptive. The auth should be correct. But should the tts endpoint be:

https://westus.tts.speech.microsoft.com/cognitiveservices/v1
revodavid commented 6 years ago

@AndreMikulec Sounds like you got an email that was misleading about the endpoint. Would you mind forwarding it to me at davidsmi@microsoft.com? I'll let the product team know.

AndreMikulec commented 6 years ago

John Muschelli,

I can not find the email about the endpoint.
But, I copied and pasted and saved the exact text of the endpoint, key 1, and key 2.
I will check that later this evening.

" Can you try the new mscstts version I just pushed

devtools::install_github("muschellij2/mscstts") " I will try during this evening.

AndreMikulec commented 6 years ago

John Muschelli,

Endpoints and Keys

Welcome to Cognitive Services!
Microsoft Azure <azure-noreply@microsoft.com>
Tue 8/21/2018, 3:18 PM
LINK
Get your keys
https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/

Speech services PREVIEW
This API key is currently active
28 days remaining (FROM AUG 22 2018)

Endpoint: https://westus.api.cognitive.microsoft.com/sts/v1.0

Key 1: 61<omitted>99

Key 2: f1<omitted>96

Docs on Speech service REST APIs 05/08/2018 https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-apis

Speech to Text
West US https://westus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1

Region  Text to Speech endpoint ( ** THIS ONE ** )
West US https://westus.tts.speech.microsoft.com/cognitiveservices/v1

Authentication
West US https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken

Above, "fix" seemed sort of flakey: is sometimes saves/does_not_save the changes

So, I switched to using an Rstudio 'project from git(github URL "muschellij2/mscstts")'

edit files

  print("tokent_url")
  print(token_url)

  print("synth_url")
  print(synth_url)

  <change synth_url>
  <change token_url>

save changed files

Below, I tried several combinations of synth_url and token_url . . .

> devtools::load_all(".")
Loading mscstts
> res = ms_synthesize(script = "hey, how are you doing? I'm doing pretty good", output_format = "audio-16khz-128kbitrate-mono-mp3")
[1] "synth_url"
[1] "https://westus.tts.speech.microsoft.com/cognitiveservices/v1"
[1] "token_url"
[1] "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken"
> tmp <- tempfile();writeBin(res$content, con = tmp);mp3 = tuneR::readMP3(tmp);tuneR::play(mp3)
# WORKS ... MS 'player' plays ... I hear words.

edit files and save files

> devtools::load_all(".")
Loading mscstts

> res = ms_synthesize(script = "hey, how are you doing? I'm doing pretty good", output_format = "audio-16khz-128kbitrate-mono-mp3")
[1] "synth_url"
[1] "https://speech.platform.bing.com/synthesize"
[1] "token_url"
[1] "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken"
 Show Traceback

 Rerun with Debug
 Error in ms_synthesize(script = "hey, how are you doing? I'm doing pretty good",  : 
  Unauthorized (HTTP 401). 

edit files and save files

> devtools::load_all(".")
Loading mscstts
> res = ms_synthesize(script = "hey, how are you doing? I'm doing pretty good", output_format = "audio-16khz-128kbitrate-mono-mp3")
[1] "synth_url"
[1] "https://api.cognitive.microsoft.com/sts/v1.0"
[1] "token_url"
[1] "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken"
 Show Traceback

 Rerun with Debug
 Error in ms_synthesize(script = "hey, how are you doing? I'm doing pretty good",  : 
  Not Found (HTTP 404). 

edit files and save files

> devtools::load_all(".")
Loading mscstts
> res = ms_synthesize(script = "hey, how are you doing? I'm doing pretty good", output_format = "audio-16khz-128kbitrate-mono-mp3")
[1] "synth_url"
[1] "https://api.cognitive.microsoft.com/sts/v1.0"
[1] "token_url"
[1] "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"
 Show Traceback

 Rerun with Debug
 Error in get_ms_tts_token(api_key = api_key) : Unauthorized (HTTP 401). 

edit files and save files

currently what is on github . . .

> devtools::load_all(".")
Loading mscstts
> res = ms_synthesize(script = "hey, how are you doing? I'm doing pretty good", output_format = "audio-16khz-128kbitrate-mono-mp3")
[1] "synth_url"
[1] "https://speech.platform.bing.com/synthesize"
[1] "tokent_url"
[1] "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"
 Show Traceback

 Rerun with Debug
 Error in get_ms_tts_token(api_key = api_key) : Unauthorized (HTTP 401). 

Git commit hash that I used.

AnonymousUser@ANONYMOUST MSYS /w/R-3.5._/mscstts
$ "C:/Program Files/Git/bin/git.exe" rev-parse HEAD
2cec8abd73925b026685b164213561da48c20a3a

AnonymousUser@ANONYMOUST MSYS /w/R-3.5._/mscstts
$ "C:/Program Files/Git/bin/git.exe" rev-parse --short HEAD
2cec8ab
> devtools::session_info()
Session info ------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, mingw32             
 ui       RStudio (1.1.453)           
 language (EN)                        
 collate  English_United States.1252  
 tz       America/Chicago             
 date     2018-08-22                  

Packages ----------------------------------------------------------------------------------------------------------
 package    * version date       source                          
 base       * 3.5.1   2018-07-02 local                           
 commonmark   1.5     2018-04-28 CRAN (R 3.5.1)                  
 compiler     3.5.1   2018-07-02 local                           
 curl         3.2     2018-03-28 CRAN (R 3.5.0)                  
 datasets   * 3.5.1   2018-07-02 local                           
 devtools     1.13.6  2018-06-27 CRAN (R 3.5.1)                  
 digest       0.6.16  2018-08-22 CRAN (R 3.5.1)                  
 graphics   * 3.5.1   2018-07-02 local                           
 grDevices  * 3.5.1   2018-07-02 local                           
 httr         1.3.1   2017-08-20 CRAN (R 3.5.0)                  
 jsonlite     1.5     2017-06-01 CRAN (R 3.5.0)                  
 magrittr   * 1.5     2014-11-22 CRAN (R 3.5.0)                  
 MASS         7.3-50  2018-04-30 CRAN (R 3.5.0)                  
 memoise      1.1.0   2017-04-21 CRAN (R 3.5.0)                  
 methods    * 3.5.1   2018-07-02 local                           
 mscstts    * 0.4.0   <NA>       local                           
 R6           2.2.2   2017-06-17 CRAN (R 3.5.0)                  
 Rcpp         0.12.18 2018-07-23 CRAN (R 3.5.1)                  
 rlang        0.2.2   2018-08-16 CRAN (R 3.5.1)                  
 roxygen2     6.1.0   2018-07-27 CRAN (R 3.5.1)                  
 signal       0.7-6   2015-07-30 CRAN (R 3.5.1)                  
 stats      * 3.5.1   2018-07-02 local                           
 stringi      1.2.4   2018-07-20 CRAN (R 3.5.1)                  
 stringr      1.3.1   2018-05-10 CRAN (R 3.5.0)                  
 testthat     2.0.0   2017-12-13 CRAN (R 3.5.0)                  
 tools        3.5.1   2018-07-02 local                           
 tuneR        1.3.3   2018-07-08 CRAN (R 3.5.1)                  
 utils      * 3.5.1   2018-07-02 local                           
 withr        2.1.2   2018-04-27 Github (jimhester/withr@79d7b0d)
 xml2         1.2.0   2018-01-24 CRAN (R 3.5.0)                  
 yaml         2.2.0   2018-07-25 CRAN (R 3.5.1)                  
muschellij2 commented 6 years ago

Did you email this to @revodavid

AndreMikulec commented 6 years ago

@muschellij2, I just sent an email to @revodavid .

AndreMikulec commented 6 years ago

@muschellij2, I just sent another email to @revodavid .

AndreMikulec commented 6 years ago

No, answer exists back from revodavid.

In may own code, I am planning to soft code in some adjustments.

AndreMikulec commented 6 years ago

@muschellij2,

I have not heard nor read anything back from @revodavid.

The case may be now that MS has many urls. These URLs may be volatile and/or user specific.

In my own code, I am thinking about doing the following.

  1. to ms_synthesize, adding the parameter: token_url.
  2. to ms_synthesize, adding the parameter: synth_url.
ms_synthesize = function(
  script,
  token = NULL,
  token_url = NULL,
  api_key = NULL,
  synth_url = NULL,
  gender = c("Female", "Male"),
  language = "en-US",
  output_format = c( "raw-16khz-16bit-mono-pcm" ,
                     "ssml-16khz-16bit-mono-tts",
                    "audio-16khz-16kbps-mono-siren",
                    "riff-16khz-16kbps-mono-siren",
                    "riff-16khz-16bit-mono-pcm",
                    "audio-16khz-128kbitrate-mono-mp3",
                    "audio-16khz-64kbitrate-mono-mp3",
                    "audio-16khz-32kbitrate-mono-mp3"),
  escape = FALSE,
  ...
  )

Then internal code may look something like

token_url <- if(is.null(token_url)) { token_url <- "<default>" } else { token_url }
synth_url <- if(is.null(synth_url)) { token_url <- "<default>" } else { synth_url }

Next, my call may look like.


res = ms_synthesize(script = "hey, how are you doing? I'm doing pretty good", 
        token_url = "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken",
        synth_url = "https://westus.tts.speech.microsoft.com/cognitiveservices/v1",
        output_format = "audio-16khz-128kbitrate-mono-mp3")

Andre Mikulec
Andre_Mikulec@Hotmail.com
AndreMikulec commented 6 years ago

@muschellij2,

For my own personal use, I made those changes mentioned above ... https://github.com/muschellij2/mscstts/compare/master...AndreMikulec:master

Maybe after my 7/30 day trial period has ended, then I will get a 'regular' endpoint ( and will not have to use a custom token_url and custom synth_url. )

AndreMikulec commented 6 years ago

Answer follows.

"is being superseded" . . . "so it will have region-specific URLs."

From: David Smith (CDA) 
Sent: Friday, August 24, 2018 11:50
To: 'Andre Mikulec' <andre_mikulec@hotmail.com>
Subject: RE: R package mscstts - Microsoft Cognitive Services changed URLs

Hi Andre,

The team is looking into the issue with the wrong endpoint being included in the email.

Bing Speech is being superseded by the new 
Speech Service https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/overview 
which I believe will be available in multiple regions, so it will have region-specific URLs.

Hope this helps,
David
muschellij2 commented 5 years ago

Can you try the new mscstts version I just pushed

devtools::install_github("muschellij2/mscstts")

and confirm the fix?

AndreMikulec commented 5 years ago

John,

Can you try the new mscstts version I just pushed . . .

Unfortunately, my TTS token has expired (and I did not renew). Therefore, I can not test.

muschellij2 commented 5 years ago

You should be able to sign up for a Free set of keys from Azure. The

(can also go to: https://portal.azure.com/#create/Microsoft.CognitiveServicesSpeechServices) https://portal.azure.com/#home

Get your API key and try it out! John

On Wed, Dec 26, 2018 at 11:45 AM AndreMikulec notifications@github.com wrote:

John,

Can you try the new mscstts version I just pushed . . .

Unfortunately, my TTS token has expired (and I did not renew). Therefore, I can not test.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/muschellij2/mscstts/issues/2#issuecomment-449991958, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrght3z4tSMwi1G0WREw8xs1j_SgOks5u86eTgaJpZM4WGjgP .