Closed Bunoviske closed 1 year ago
Hi Bruno,
As a quick check, can you confirm that your credentials work with our HTTP API? For example, you could try this endpoint to list the available models:
curl -u bruno@email.com:mypassword https://brain.deepgram.com/v2/models
At a glance, your config looks valid, so if the above works but the MRCP plugin doesn't, then we may have a trickier issue.
Hello Anthony,
I tried what you suggested and I received this:
{
"error":"Unauthorized",
"reason":"No information available.",
"transaction_key":"dD+Rm7umV2YgvqEkOhLokQxLoqsng0cMkDDnuxHm0rGam5rTg7p1g1GoVjlxMynOvsQ7NAJG93Ymup0Btjw4crN3uUeC47np3GxVq0us/am/4gMcxGv/Lk8U+1XrGNuyTBHWx+TmnMxtXNGq9jAWA/LolcBz+pVAJiGJ4vE4",
"request_id":"m0rJtFo0D0wclLlaP49ekWPsD8FlUHYb"
}
It works If I use my API key on this url: https://api.deepgram.com/v1/. For example, I could get all my projects running:
curl --request GET \
--url https://api.deepgram.com/v1/projects \
--header 'Authorization: Token <YOUR_DEEPGRAM_API_KEY>' \
--header 'content-type: application/json'
Oh! This makes sense now. Deepgram recently launched a new version of the API, at https://api.deepgram.com/v1/
(which is what everything at https://console.deepgram.com refers to) and we're gradually migrating users away from https://brain.deepgram.com/v2
. (Don't let the /v1
and /v2
fool you -- it's a new domain, so we started the version number over again).
The WebSocket protocol is identical, so things should generally work the same way, but one thing that did change is auth. The old API is expecting a header that looks like Authorization: Basic $(user:pass | base64)
whereas the new API expects Authorization: Token $API_KEY
. This repo hasn't been updated to work with the new auth.
The code that handles this is at https://github.com/deepgram/dgmrcp/blob/4a0d45baa4034a373b2850dccf13b04931e1ecb7/src/channel.rs#L339-L342 and https://github.com/deepgram/dgmrcp/blob/4a0d45baa4034a373b2850dccf13b04931e1ecb7/src/channel.rs#L356-L361. PR's are welcome, of course, if you need this change to unblock your work! Otherwise, we'll make sure it's on our todo list.
I changed the URL to the new API, that is the new error (404 Not Found):
2022-04-01 22:42:47:341517 [INFO] Process RECOGNIZE Request <eb8f400e7a4f4b53@speechrecog> [2]
2022-04-01 22:42:47:341553 [NOTICE] [DG :: dgmrcp::channel] Channel::recognize
2022-04-01 22:42:47:341604 [NOTICE] [DG :: dgmrcp::channel] Building request to wss://api.deepgram.com/v1/listen/stream?endpointing=true&interim_results=true&encoding=linear16&sample_rate=8000&channels=1&language=de
2022-04-01 22:42:47:341720 [NOTICE] [DG :: dgmrcp::channel] Opening websocket connection
2022-04-01 22:42:47:341828 [NOTICE] [DG :: dgmrcp::channel] handled RECOGNIZE request
2022-04-01 22:42:47:341856 [INFO] Process RECOGNIZE Response <eb8f400e7a4f4b53@speechrecog> [2]
2022-04-01 22:42:47:341863 [INFO] State Transition IDLE -> RECOGNIZING <eb8f400e7a4f4b53@speechrecog>
2022-04-01 22:42:47:341890 [INFO] Send MRCPv2 Data 10.148.16.121:1544 <-> 10.148.16.121:47774 [83 bytes]
MRCP/2.0 83 2 200 IN-PROGRESS
Channel-Identifier: eb8f400e7a4f4b53@speechrecog
2022-04-01 22:42:47:512300 [INFO] [DG :: rustls::client::hs] No cached session for DNSNameRef("api.deepgram.com")
2022-04-01 22:42:47:512444 [INFO] [DG :: rustls::client::hs] Not resuming any session
2022-04-01 22:42:47:672933 [INFO] [DG :: rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256
2022-04-01 22:42:47:673351 [INFO] [DG :: rustls::client::tls13] Not resuming
2022-04-01 22:42:47:673452 [INFO] [DG :: rustls::client::tls13] TLS1.3 encrypted extensions: []
2022-04-01 22:42:47:673471 [INFO] [DG :: rustls::client::hs] ALPN protocol is None
2022-04-01 22:42:47:675188 [INFO] [DG :: rustls::client::tls13] Ticket saved
2022-04-01 22:42:47:989329 [ERROR] [DG :: dgmrcp::channel] Failed to open WebSocket connection: HTTP error: 404 Not Found
2022-04-01 22:42:47:989515 [INFO] [DG :: dgmrcp::channel] send recognition complete
2022-04-01 22:42:47:989650 [INFO] Process RECOGNITION-COMPLETE Event <eb8f400e7a4f4b53@speechrecog> [2]
2022-04-01 22:42:47:989667 [INFO] State Transition RECOGNIZING -> RECOGNIZED <eb8f400e7a4f4b53@speechrecog>
2022-04-01 22:42:47:989710 [INFO] Send MRCPv2 Data 10.148.16.121:1544 <-> 10.148.16.121:47774 [239 bytes]
MRCP/2.0 239 RECOGNITION-COMPLETE 2 COMPLETE
Channel-Identifier: eb8f400e7a4f4b53@speechrecog
Completion-Cause: 006 recognizer-error
Completion-Reason: Check that credentials are properly configured and the requested model is valid.
I missed this before, but the other difference between the APIs is the path -- the old API uses /listen/stream
whereas the new API just uses /listen
(docs).
This is hardcoded at https://github.com/deepgram/dgmrcp/blob/4a0d45baa4034a373b2850dccf13b04931e1ecb7/src/channel.rs#L883 -- changing that line to just .join("listen")
should fix it.
Thanks for bearing with me here -- this MRCP plugin predates the new API, and we're still in the transition phase between the old and the new APIs.
Uhuuuu! It worked, that is nice. I integrated with Asterisk, looks pretty good. I had never seen a rust code before and I wasn't very interested in learning it, so excuse me any redundancy in the code. I will create the PR next week, enjoy the weekend ;)
Hello,
I am receiving the following Unauthorized Error when I run ./unimrcpserver:
I configured the plugin-factory like this:
Is there any issue? I tried using my API Key as well but it did not work.
Thanks, Bruno