@deepgram/sdk 1.2.2 → 1.3.1-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.devcontainer/Dockerfile +16 -0
  2. package/.devcontainer/devcontainer.json +29 -0
  3. package/CHANGELOG.md +196 -163
  4. package/CODE_OF_CONDUCT.md +127 -127
  5. package/CONTRIBUTING.md +50 -50
  6. package/LICENSE +21 -21
  7. package/README.md +151 -151
  8. package/dist/billing.d.ts +18 -0
  9. package/dist/billing.js +73 -0
  10. package/dist/billing.js.map +1 -0
  11. package/dist/constants/defaultOptions.d.ts +6 -6
  12. package/dist/constants/defaultOptions.js +9 -9
  13. package/dist/constants/defaultOptions.js.map +0 -0
  14. package/dist/constants/index.d.ts +1 -1
  15. package/dist/constants/index.js +17 -13
  16. package/dist/constants/index.js.map +1 -1
  17. package/dist/enums/alternatives.d.ts +4 -4
  18. package/dist/enums/alternatives.js +2 -2
  19. package/dist/enums/alternatives.js.map +0 -0
  20. package/dist/enums/connectionState.d.ts +6 -6
  21. package/dist/enums/connectionState.js +10 -10
  22. package/dist/enums/connectionState.js.map +0 -0
  23. package/dist/enums/diarization.d.ts +4 -4
  24. package/dist/enums/diarization.js +2 -2
  25. package/dist/enums/diarization.js.map +0 -0
  26. package/dist/enums/index.d.ts +7 -7
  27. package/dist/enums/index.js +23 -19
  28. package/dist/enums/index.js.map +1 -1
  29. package/dist/enums/liveTranscriptionEvents.d.ts +6 -6
  30. package/dist/enums/liveTranscriptionEvents.js +2 -2
  31. package/dist/enums/liveTranscriptionEvents.js.map +0 -0
  32. package/dist/enums/models.d.ts +5 -5
  33. package/dist/enums/models.js +2 -2
  34. package/dist/enums/models.js.map +0 -0
  35. package/dist/enums/punctuation.d.ts +4 -4
  36. package/dist/enums/punctuation.js +2 -2
  37. package/dist/enums/punctuation.js.map +0 -0
  38. package/dist/enums/searchKind.d.ts +4 -4
  39. package/dist/enums/searchKind.js +2 -2
  40. package/dist/enums/searchKind.js.map +0 -0
  41. package/dist/helpers/index.d.ts +1 -1
  42. package/dist/helpers/index.js +17 -13
  43. package/dist/helpers/index.js.map +1 -1
  44. package/dist/helpers/secondsToTimestamp.d.ts +1 -1
  45. package/dist/helpers/secondsToTimestamp.js +7 -7
  46. package/dist/helpers/secondsToTimestamp.js.map +0 -0
  47. package/dist/httpRequest.d.ts +3 -3
  48. package/dist/httpRequest.js +90 -90
  49. package/dist/httpRequest.js.map +1 -1
  50. package/dist/index.d.ts +25 -17
  51. package/dist/index.js +40 -32
  52. package/dist/index.js.map +1 -1
  53. package/dist/invitation.d.ts +29 -0
  54. package/dist/invitation.js +99 -0
  55. package/dist/invitation.js.map +1 -0
  56. package/dist/keys.d.ts +32 -32
  57. package/dist/keys.js +131 -111
  58. package/dist/keys.js.map +1 -1
  59. package/dist/members.d.ts +18 -0
  60. package/dist/members.js +73 -0
  61. package/dist/members.js.map +1 -0
  62. package/dist/projects.d.ts +21 -21
  63. package/dist/projects.js +81 -81
  64. package/dist/projects.js.map +1 -1
  65. package/dist/scopes.d.ts +20 -0
  66. package/dist/scopes.js +77 -0
  67. package/dist/scopes.js.map +1 -0
  68. package/dist/transcription/index.d.ts +18 -18
  69. package/dist/transcription/index.js +71 -71
  70. package/dist/transcription/index.js.map +0 -0
  71. package/dist/transcription/liveTranscription.d.ts +23 -23
  72. package/dist/transcription/liveTranscription.js +82 -82
  73. package/dist/transcription/liveTranscription.js.map +1 -1
  74. package/dist/transcription/preRecordedTranscription.d.ts +8 -8
  75. package/dist/transcription/preRecordedTranscription.js +113 -113
  76. package/dist/transcription/preRecordedTranscription.js.map +1 -1
  77. package/dist/types/balance.d.ts +6 -0
  78. package/dist/types/balance.js +3 -0
  79. package/dist/types/balance.js.map +1 -0
  80. package/dist/types/balanceList.d.ts +4 -0
  81. package/dist/types/balanceList.js +3 -0
  82. package/dist/types/balanceList.js.map +1 -0
  83. package/dist/types/channel.d.ts +25 -25
  84. package/dist/types/channel.js +2 -2
  85. package/dist/types/channel.js.map +0 -0
  86. package/dist/types/createKeyOptions.d.ts +13 -13
  87. package/dist/types/createKeyOptions.js +2 -2
  88. package/dist/types/createKeyOptions.js.map +0 -0
  89. package/dist/types/hit.d.ts +21 -21
  90. package/dist/types/hit.js +2 -2
  91. package/dist/types/hit.js.map +0 -0
  92. package/dist/types/index.d.ts +35 -28
  93. package/dist/types/index.js +51 -40
  94. package/dist/types/index.js.map +1 -1
  95. package/dist/types/invitationList.d.ts +4 -0
  96. package/dist/types/invitationList.js +3 -0
  97. package/dist/types/invitationList.js.map +1 -0
  98. package/dist/types/invitationOptions.d.ts +4 -0
  99. package/dist/types/invitationOptions.js +3 -0
  100. package/dist/types/invitationOptions.js.map +1 -0
  101. package/dist/types/key.d.ts +25 -25
  102. package/dist/types/key.js +2 -2
  103. package/dist/types/key.js.map +0 -0
  104. package/dist/types/keyResponse.d.ts +50 -10
  105. package/dist/types/keyResponse.js +2 -2
  106. package/dist/types/keyResponse.js.map +0 -0
  107. package/dist/types/keyword.d.ts +4 -4
  108. package/dist/types/keyword.js +2 -2
  109. package/dist/types/keyword.js.map +0 -0
  110. package/dist/types/liveTranscriptionOptions.d.ts +148 -148
  111. package/dist/types/liveTranscriptionOptions.js +2 -2
  112. package/dist/types/liveTranscriptionOptions.js.map +0 -0
  113. package/dist/types/liveTranscriptionResponse.d.ts +9 -9
  114. package/dist/types/liveTranscriptionResponse.js +2 -2
  115. package/dist/types/liveTranscriptionResponse.js.map +0 -0
  116. package/dist/types/member.d.ts +7 -6
  117. package/dist/types/member.js +2 -2
  118. package/dist/types/member.js.map +0 -0
  119. package/dist/types/memberList.d.ts +4 -0
  120. package/dist/types/memberList.js +3 -0
  121. package/dist/types/memberList.js.map +1 -0
  122. package/dist/types/message.d.ts +3 -0
  123. package/dist/types/message.js +3 -0
  124. package/dist/types/message.js.map +1 -0
  125. package/dist/types/metadata.d.ts +8 -8
  126. package/dist/types/metadata.js +2 -2
  127. package/dist/types/metadata.js.map +0 -0
  128. package/dist/types/prerecordedTranscriptionOptions.d.ts +126 -126
  129. package/dist/types/prerecordedTranscriptionOptions.js +2 -2
  130. package/dist/types/prerecordedTranscriptionOptions.js.map +0 -0
  131. package/dist/types/prerecordedTranscriptionResponse.d.ts +25 -25
  132. package/dist/types/prerecordedTranscriptionResponse.js +50 -50
  133. package/dist/types/prerecordedTranscriptionResponse.js.map +1 -1
  134. package/dist/types/project.d.ts +17 -17
  135. package/dist/types/project.js +2 -2
  136. package/dist/types/project.js.map +0 -0
  137. package/dist/types/projectPatchResponse.d.ts +6 -6
  138. package/dist/types/projectPatchResponse.js +2 -2
  139. package/dist/types/projectPatchResponse.js.map +0 -0
  140. package/dist/types/projectResponse.d.ts +4 -4
  141. package/dist/types/projectResponse.js +2 -2
  142. package/dist/types/projectResponse.js.map +0 -0
  143. package/dist/types/scopeList.d.ts +3 -0
  144. package/dist/types/scopeList.js +3 -0
  145. package/dist/types/scopeList.js.map +1 -0
  146. package/dist/types/search.d.ts +14 -14
  147. package/dist/types/search.js +2 -2
  148. package/dist/types/search.js.map +0 -0
  149. package/dist/types/transcriptionSource.d.ts +14 -14
  150. package/dist/types/transcriptionSource.js +2 -2
  151. package/dist/types/transcriptionSource.js.map +0 -0
  152. package/dist/types/usageCallback.d.ts +4 -4
  153. package/dist/types/usageCallback.js +2 -2
  154. package/dist/types/usageCallback.js.map +0 -0
  155. package/dist/types/usageField.d.ts +7 -7
  156. package/dist/types/usageField.js +2 -2
  157. package/dist/types/usageField.js.map +0 -0
  158. package/dist/types/usageFieldOptions.d.ts +4 -4
  159. package/dist/types/usageFieldOptions.js +2 -2
  160. package/dist/types/usageFieldOptions.js.map +0 -0
  161. package/dist/types/usageOptions.d.ts +23 -23
  162. package/dist/types/usageOptions.js +2 -2
  163. package/dist/types/usageOptions.js.map +0 -0
  164. package/dist/types/usageRequest.d.ts +11 -11
  165. package/dist/types/usageRequest.js +2 -2
  166. package/dist/types/usageRequest.js.map +0 -0
  167. package/dist/types/usageRequestDetail.d.ts +30 -30
  168. package/dist/types/usageRequestDetail.js +2 -2
  169. package/dist/types/usageRequestDetail.js.map +0 -0
  170. package/dist/types/usageRequestList.d.ts +6 -6
  171. package/dist/types/usageRequestList.js +2 -2
  172. package/dist/types/usageRequestList.js.map +0 -0
  173. package/dist/types/usageRequestListOptions.d.ts +7 -7
  174. package/dist/types/usageRequestListOptions.js +2 -2
  175. package/dist/types/usageRequestListOptions.js.map +0 -0
  176. package/dist/types/usageRequestMessage.d.ts +3 -3
  177. package/dist/types/usageRequestMessage.js +2 -2
  178. package/dist/types/usageRequestMessage.js.map +0 -0
  179. package/dist/types/usageResponse.d.ts +10 -10
  180. package/dist/types/usageResponse.js +2 -2
  181. package/dist/types/usageResponse.js.map +0 -0
  182. package/dist/types/usageResponseDetail.d.ts +6 -6
  183. package/dist/types/usageResponseDetail.js +2 -2
  184. package/dist/types/usageResponseDetail.js.map +0 -0
  185. package/dist/types/utterance.d.ts +39 -39
  186. package/dist/types/utterance.js +2 -2
  187. package/dist/types/utterance.js.map +0 -0
  188. package/dist/types/wordBase.d.ts +8 -8
  189. package/dist/types/wordBase.js +2 -2
  190. package/dist/types/wordBase.js.map +0 -0
  191. package/dist/usage.d.ts +34 -34
  192. package/dist/usage.js +121 -121
  193. package/dist/usage.js.map +1 -1
  194. package/dist/userAgent.d.ts +1 -1
  195. package/dist/userAgent.js +19 -20
  196. package/dist/userAgent.js.map +1 -1
  197. package/package.json +59 -57
package/CONTRIBUTING.md CHANGED
@@ -1,50 +1,50 @@
1
- # Contributing Guidelines
2
-
3
- Want to contribute to this project? We ❤️ it!
4
-
5
- Here are a few types of contributions that we would be interested in hearing about.
6
-
7
- - Bug fixes
8
- - If you find a bug, please first report it using Github Issues.
9
- - Issues that have already been identified as a bug will be labeled `🐛 bug`.
10
- - If you'd like to submit a fix for a bug, send a Pull Request from your own fork and mention the Issue number.
11
- - Include a test that isolates the bug and verifies that it was fixed.
12
- - New Features
13
- - If you'd like to accomplish something in the extension that it doesn't already do, describe the problem in a new Github Issue.
14
- - Issues that have been identified as a feature request will be labeled `✨ enhancement`.
15
- - If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending
16
- too much time writing the code. In some cases, `✨ enhancement`s may not align well with the project objectives at
17
- the time.
18
- - Tests, Documentation, Miscellaneous
19
- - If you think the test coverage could be improved, the documentation could be clearer, you've got an alternative
20
- implementation of something that may have more advantages, or any other change we would still be glad hear about
21
- it.
22
- - If its a trivial change, go ahead and send a Pull Request with the changes you have in mind
23
- - If not, open a Github Issue to discuss the idea first.
24
- - Snippets
25
- - To add snippets:
26
- - Add a directory in the `snippets` folder with the name of the language.
27
- - Add one or more files in the language directory with snippets.
28
- - Update the `package.json` to include the snippets you added.
29
-
30
- We also welcome anyone to work on any existing issues with the `👋🏽 good first issue` tag.
31
-
32
- ## Requirements
33
-
34
- For a contribution to be accepted:
35
-
36
- - The test suite must be complete and pass
37
- - Code must follow existing styling conventions
38
- - Commit messages must be descriptive. Related issues should be mentioned by number.
39
-
40
- If the contribution doesn't meet these criteria, a maintainer will discuss it with you on the Issue. You can still
41
- continue to add more commits to the branch you have sent the Pull Request from.
42
-
43
- ## How To
44
-
45
- 1. Fork this repository on GitHub.
46
- 1. Clone/fetch your fork to your local development machine.
47
- 1. Create a new branch (e.g. `issue-12`, `feat.add_foo`, etc) and check it out.
48
- 1. Make your changes and commit them. (Did the tests pass? No linting errors?)
49
- 1. Push your new branch to your fork. (e.g. `git push myname issue-12`)
50
- 1. Open a Pull Request from your new branch to the original fork's `main` branch.
1
+ # Contributing Guidelines
2
+
3
+ Want to contribute to this project? We ❤️ it!
4
+
5
+ Here are a few types of contributions that we would be interested in hearing about.
6
+
7
+ - Bug fixes
8
+ - If you find a bug, please first report it using Github Issues.
9
+ - Issues that have already been identified as a bug will be labeled `🐛 bug`.
10
+ - If you'd like to submit a fix for a bug, send a Pull Request from your own fork and mention the Issue number.
11
+ - Include a test that isolates the bug and verifies that it was fixed.
12
+ - New Features
13
+ - If you'd like to accomplish something in the extension that it doesn't already do, describe the problem in a new Github Issue.
14
+ - Issues that have been identified as a feature request will be labeled `✨ enhancement`.
15
+ - If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending
16
+ too much time writing the code. In some cases, `✨ enhancement`s may not align well with the project objectives at
17
+ the time.
18
+ - Tests, Documentation, Miscellaneous
19
+ - If you think the test coverage could be improved, the documentation could be clearer, you've got an alternative
20
+ implementation of something that may have more advantages, or any other change we would still be glad hear about
21
+ it.
22
+ - If its a trivial change, go ahead and send a Pull Request with the changes you have in mind
23
+ - If not, open a Github Issue to discuss the idea first.
24
+ - Snippets
25
+ - To add snippets:
26
+ - Add a directory in the `snippets` folder with the name of the language.
27
+ - Add one or more files in the language directory with snippets.
28
+ - Update the `package.json` to include the snippets you added.
29
+
30
+ We also welcome anyone to work on any existing issues with the `👋🏽 good first issue` tag.
31
+
32
+ ## Requirements
33
+
34
+ For a contribution to be accepted:
35
+
36
+ - The test suite must be complete and pass
37
+ - Code must follow existing styling conventions
38
+ - Commit messages must be descriptive. Related issues should be mentioned by number.
39
+
40
+ If the contribution doesn't meet these criteria, a maintainer will discuss it with you on the Issue. You can still
41
+ continue to add more commits to the branch you have sent the Pull Request from.
42
+
43
+ ## How To
44
+
45
+ 1. Fork this repository on GitHub.
46
+ 1. Clone/fetch your fork to your local development machine.
47
+ 1. Create a new branch (e.g. `issue-12`, `feat.add_foo`, etc) and check it out.
48
+ 1. Make your changes and commit them. (Did the tests pass? No linting errors?)
49
+ 1. Push your new branch to your fork. (e.g. `git push myname issue-12`)
50
+ 1. Open a Pull Request from your new branch to the original fork's `main` branch.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 deepgram
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 deepgram
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,151 +1,151 @@
1
- # Deepgram Node.js SDK
2
-
3
- [![CI](https://github.com/deepgram/node-sdk/actions/workflows/CI.yml/badge.svg)](https://github.com/deepgram/node-sdk/actions/workflows/CI.yml) [![npm (scoped)](https://img.shields.io/npm/v/@deepgram/sdk)](https://www.npmjs.com/package/@deepgram/sdk) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-rounded)](CODE_OF_CONDUCT.md)
4
-
5
- Official Node.js SDK for [Deepgram](https://www.deepgram.com/)'s automated
6
- speech recognition APIs.
7
-
8
- > This SDK only supports hosted usage of api.deepgram.com.
9
-
10
- To access the API you will need a Deepgram account. Sign up for free at
11
- [signup][signup].
12
-
13
- ## Documentation
14
-
15
- Full documentation of the Node.js SDK can be found on the
16
- [Deepgram Developer Portal](https://developers.deepgram.com/sdks-tools/sdks/node-sdk/).
17
-
18
- You can learn more about the full Deepgram API at [https://developers.deepgram.com](https://developers.deepgram.com).
19
-
20
- ## Installation
21
-
22
- ### With NPM
23
-
24
- ```bash
25
- npm install @deepgram/sdk
26
- ```
27
-
28
- ### With Yarn
29
-
30
- ```bash
31
- yarn add @deepgram/sdk
32
- ```
33
-
34
- ## Constructor
35
-
36
- ```js
37
- const { Deepgram } = require("@deepgram/sdk");
38
-
39
- const deepgram = new Deepgram(DEEPGRAM_API_KEY);
40
- ```
41
-
42
- ## Examples
43
-
44
- ### Transcribe an Existing File
45
-
46
- #### Remote Files
47
-
48
- ```js
49
- const fileSource = { url: URL_OF_FILE };
50
-
51
- const response = await deepgram.transcription.preRecorded(fileSource, {
52
- punctuate: true,
53
- });
54
- ```
55
-
56
- #### Local Files
57
-
58
- ```js
59
- const streamSource = {
60
- stream: fs.createReadStream("/path/to/file"),
61
- mimetype: MIMETYPE_OF_FILE,
62
- };
63
-
64
- const response = await deepgram.transcription.preRecorded(streamSource, {
65
- punctuate: true,
66
- });
67
- ```
68
-
69
- ### Transcribe Audio in Real-Time
70
-
71
- ```js
72
- navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
73
- const mediaRecorder = new MediaRecorder(stream, {
74
- mimeType: 'audio/webm',
75
- });
76
- const deepgramSocket = deepgram.transcription.live({ punctuate: true });
77
-
78
- deepgramSocket.addListener('open', () => {
79
- mediaRecorder.addEventListener('dataavailable', async (event) => {
80
- if (event.data.size > 0 && deepgramSocket.readyState == 1) {
81
- deepgramSocket.send(event.data)
82
- }
83
- })
84
- mediaRecorder.start(1000)
85
- });
86
-
87
- deepgramSocket.addListener("transcriptReceived", (received) => {
88
- const transcript = received.channel.alternatives[0].transcript;
89
- if (transcript && received.is_final) {
90
- console.log(transcript);
91
- }
92
- });
93
- });
94
- ```
95
-
96
- ## Samples
97
-
98
- To run the sample code, first run the following in your terminal:
99
-
100
- ```bash
101
- npm install
102
- npm build
103
- ```
104
-
105
- Then update the config object located at the top of the `index.js`
106
- file in the sample folder.
107
-
108
- ```js
109
- const config = {
110
- deepgramApiKey: "YOUR_DEEPGRAM_API_KEY",
111
- urlToFile:
112
- "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav",
113
- };
114
- ```
115
-
116
- Finally, run the sample code using the following command in your terminal:
117
-
118
- ```bash
119
- node sample/index.js
120
- ```
121
-
122
- The sample demonstrates the following uses:
123
-
124
- - Transcribing a prerecorded file
125
- - Retrieving usage for a project
126
- - Getting a project
127
- - Creating an API key
128
- - Deleting an API key
129
-
130
- ## Development and Contributing
131
-
132
- Interested in contributing? We ❤️ pull requests!
133
-
134
- To make sure our community is safe for all, be sure to review and agree to our
135
- [Code of Conduct](./CODE_OF_CONDUCT.md). Then see the
136
- [Contribution](./CONTRIBUTING.md) guidelines for more information.
137
-
138
- ## Getting Help
139
-
140
- We love to hear from you so if you have questions, comments or find a bug in the
141
- project, let us know! You can either:
142
-
143
- - [Open an issue](https://github.com/deepgram/node-sdk/issues/new) on this repository
144
- - Tweet at us! We're [@DeepgramDevs on Twitter](https://twitter.com/DeepgramDevs)
145
-
146
- ## Further Reading
147
-
148
- Check out the Developer Documentation at [https://developers.deepgram.com/](https://developers.deepgram.com/)
149
-
150
- [signup]: https://console.deepgram.com?utm_source=node-sdk&utm_content=readme
151
- [license]: LICENSE.txt
1
+ # Deepgram Node.js SDK
2
+
3
+ [![CI](https://github.com/deepgram/node-sdk/actions/workflows/CI.yml/badge.svg)](https://github.com/deepgram/node-sdk/actions/workflows/CI.yml) [![npm (scoped)](https://img.shields.io/npm/v/@deepgram/sdk)](https://www.npmjs.com/package/@deepgram/sdk) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-rounded)](CODE_OF_CONDUCT.md)
4
+
5
+ Official Node.js SDK for [Deepgram](https://www.deepgram.com/)'s automated
6
+ speech recognition APIs.
7
+
8
+ > This SDK only supports hosted usage of api.deepgram.com.
9
+
10
+ To access the API you will need a Deepgram account. Sign up for free at
11
+ [signup][signup].
12
+
13
+ ## Documentation
14
+
15
+ Full documentation of the Node.js SDK can be found on the
16
+ [Deepgram Developer Portal](https://developers.deepgram.com/sdks-tools/sdks/node-sdk/).
17
+
18
+ You can learn more about the full Deepgram API at [https://developers.deepgram.com](https://developers.deepgram.com).
19
+
20
+ ## Installation
21
+
22
+ ### With NPM
23
+
24
+ ```bash
25
+ npm install @deepgram/sdk
26
+ ```
27
+
28
+ ### With Yarn
29
+
30
+ ```bash
31
+ yarn add @deepgram/sdk
32
+ ```
33
+
34
+ ## Constructor
35
+
36
+ ```js
37
+ const { Deepgram } = require("@deepgram/sdk");
38
+
39
+ const deepgram = new Deepgram(DEEPGRAM_API_KEY);
40
+ ```
41
+
42
+ ## Examples
43
+
44
+ ### Transcribe an Existing File
45
+
46
+ #### Remote Files
47
+
48
+ ```js
49
+ const fileSource = { url: URL_OF_FILE };
50
+
51
+ const response = await deepgram.transcription.preRecorded(fileSource, {
52
+ punctuate: true,
53
+ });
54
+ ```
55
+
56
+ #### Local Files
57
+
58
+ ```js
59
+ const streamSource = {
60
+ stream: fs.createReadStream("/path/to/file"),
61
+ mimetype: MIMETYPE_OF_FILE,
62
+ };
63
+
64
+ const response = await deepgram.transcription.preRecorded(streamSource, {
65
+ punctuate: true,
66
+ });
67
+ ```
68
+
69
+ ### Transcribe Audio in Real-Time
70
+
71
+ ```js
72
+ navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
73
+ const mediaRecorder = new MediaRecorder(stream, {
74
+ mimeType: 'audio/webm',
75
+ });
76
+ const deepgramSocket = deepgram.transcription.live({ punctuate: true });
77
+
78
+ deepgramSocket.addListener('open', () => {
79
+ mediaRecorder.addEventListener('dataavailable', async (event) => {
80
+ if (event.data.size > 0 && deepgramSocket.readyState == 1) {
81
+ deepgramSocket.send(event.data)
82
+ }
83
+ })
84
+ mediaRecorder.start(1000)
85
+ });
86
+
87
+ deepgramSocket.addListener("transcriptReceived", (received) => {
88
+ const transcript = received.channel.alternatives[0].transcript;
89
+ if (transcript && received.is_final) {
90
+ console.log(transcript);
91
+ }
92
+ });
93
+ });
94
+ ```
95
+
96
+ ## Samples
97
+
98
+ To run the sample code, first run the following in your terminal:
99
+
100
+ ```bash
101
+ npm install
102
+ npm build
103
+ ```
104
+
105
+ Then update the config object located at the top of the `index.js`
106
+ file in the sample folder.
107
+
108
+ ```js
109
+ const config = {
110
+ deepgramApiKey: "YOUR_DEEPGRAM_API_KEY",
111
+ urlToFile:
112
+ "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav",
113
+ };
114
+ ```
115
+
116
+ Finally, run the sample code using the following command in your terminal:
117
+
118
+ ```bash
119
+ node sample/index.js
120
+ ```
121
+
122
+ The sample demonstrates the following uses:
123
+
124
+ - Transcribing a prerecorded file
125
+ - Retrieving usage for a project
126
+ - Getting a project
127
+ - Creating an API key
128
+ - Deleting an API key
129
+
130
+ ## Development and Contributing
131
+
132
+ Interested in contributing? We ❤️ pull requests!
133
+
134
+ To make sure our community is safe for all, be sure to review and agree to our
135
+ [Code of Conduct](./CODE_OF_CONDUCT.md). Then see the
136
+ [Contribution](./CONTRIBUTING.md) guidelines for more information.
137
+
138
+ ## Getting Help
139
+
140
+ We love to hear from you so if you have questions, comments or find a bug in the
141
+ project, let us know! You can either:
142
+
143
+ - [Open an issue](https://github.com/deepgram/node-sdk/issues/new) on this repository
144
+ - Tweet at us! We're [@DeepgramDevs on Twitter](https://twitter.com/DeepgramDevs)
145
+
146
+ ## Further Reading
147
+
148
+ Check out the Developer Documentation at [https://developers.deepgram.com/](https://developers.deepgram.com/)
149
+
150
+ [signup]: https://console.deepgram.com/signup?utm_medium=github&utm_source=DEVREL&utm_content=node-sdk
151
+ [license]: LICENSE.txt
@@ -0,0 +1,18 @@
1
+ import { BalanceList, Balance } from "./types";
2
+ export declare class Billing {
3
+ private _credentials;
4
+ private _apiUrl;
5
+ constructor(_credentials: string, _apiUrl: string);
6
+ private apiPath;
7
+ /**
8
+ * Retrieves list of balance info of the specified project.
9
+ * @param projectId Unique identifier of the project
10
+ */
11
+ listBalances(projectId: string): Promise<BalanceList>;
12
+ /**
13
+ * Retrieves balance info of a specified balance_id in the specified project.
14
+ * @param projectId Unique identifier of the project
15
+ * @param balanceId Unique identifier of the balance
16
+ */
17
+ getBalance(projectId: string, balanceId: string): Promise<Balance>;
18
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Billing = void 0;
40
+ var httpRequest_1 = require("./httpRequest");
41
+ var Billing = /** @class */ (function () {
42
+ function Billing(_credentials, _apiUrl) {
43
+ this._credentials = _credentials;
44
+ this._apiUrl = _apiUrl;
45
+ this.apiPath = "/v1/projects";
46
+ }
47
+ /**
48
+ * Retrieves list of balance info of the specified project.
49
+ * @param projectId Unique identifier of the project
50
+ */
51
+ Billing.prototype.listBalances = function (projectId) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ return __generator(this, function (_a) {
54
+ return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, "".concat(this.apiPath, "/").concat(projectId, "/balances"))];
55
+ });
56
+ });
57
+ };
58
+ /**
59
+ * Retrieves balance info of a specified balance_id in the specified project.
60
+ * @param projectId Unique identifier of the project
61
+ * @param balanceId Unique identifier of the balance
62
+ */
63
+ Billing.prototype.getBalance = function (projectId, balanceId) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ return __generator(this, function (_a) {
66
+ return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, "".concat(this.apiPath, "/").concat(projectId, "/balances/").concat(balanceId))];
67
+ });
68
+ });
69
+ };
70
+ return Billing;
71
+ }());
72
+ exports.Billing = Billing;
73
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC;IACE,iBAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;;OAGG;IACG,8BAAY,GAAlB,UAAmB,SAAiB;;;gBAClC,sBAAO,IAAA,sBAAQ,EACb,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACZ,UAAG,IAAI,CAAC,OAAO,cAAI,SAAS,cAAW,CACxC,EAAC;;;KACH;IAED;;;;OAIG;IAEG,4BAAU,GAAhB,UAAiB,SAAiB,EAAE,SAAiB;;;gBACnD,sBAAO,IAAA,sBAAQ,EACb,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACZ,UAAG,IAAI,CAAC,OAAO,cAAI,SAAS,uBAAa,SAAS,CAAE,CACrD,EAAC;;;KACH;IACH,cAAC;AAAD,CAAC,AAhCD,IAgCC;AAhCY,0BAAO"}
@@ -1,6 +1,6 @@
1
- /**
2
- * Default SDK options
3
- */
4
- export declare const DefaultOptions: {
5
- apiUrl: string;
6
- };
1
+ /**
2
+ * Default SDK options
3
+ */
4
+ export declare const DefaultOptions: {
5
+ apiUrl: string;
6
+ };
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultOptions = void 0;
4
- /**
5
- * Default SDK options
6
- */
7
- exports.DefaultOptions = {
8
- apiUrl: "api.deepgram.com",
9
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultOptions = void 0;
4
+ /**
5
+ * Default SDK options
6
+ */
7
+ exports.DefaultOptions = {
8
+ apiUrl: "api.deepgram.com",
9
+ };
10
10
  //# sourceMappingURL=defaultOptions.js.map
File without changes
@@ -1 +1 @@
1
- export * from "./defaultOptions";
1
+ export * from "./defaultOptions";
@@ -1,14 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./defaultOptions"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./defaultOptions"), exports);
14
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -1,4 +1,4 @@
1
- export declare const enum Alternatives {
2
- One = "one-alternative",
3
- Multiple = "multiple-alternatives"
4
- }
1
+ export declare const enum Alternatives {
2
+ One = "one-alternative",
3
+ Multiple = "multiple-alternatives"
4
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=alternatives.js.map
File without changes
@@ -1,6 +1,6 @@
1
- export declare enum ConnectionState {
2
- CONNECTING = 0,
3
- OPEN = 1,
4
- CLOSING = 2,
5
- CLOSED = 3
6
- }
1
+ export declare enum ConnectionState {
2
+ CONNECTING = 0,
3
+ OPEN = 1,
4
+ CLOSING = 2,
5
+ CLOSED = 3
6
+ }