{"id":22076408,"url":"https://github.com/shadowshahriar/speech-services","last_synced_at":"2026-07-02T13:41:17.087Z","repository":{"id":261424877,"uuid":"870341142","full_name":"ShadowShahriar/speech-services","owner":"ShadowShahriar","description":"This repository demonstrates the usage of Microsoft Azure Text-to-Speech (TTS) and Speech-to-Text (STT) services for Bengali and English languages.","archived":false,"fork":false,"pushed_at":"2024-11-06T13:05:42.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T18:06:06.357Z","etag":null,"topics":["language-services","microsoft-azure","speech-services"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShadowShahriar.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-09T21:32:06.000Z","updated_at":"2025-08-30T20:38:01.000Z","dependencies_parsed_at":"2024-11-06T14:19:38.427Z","dependency_job_id":null,"html_url":"https://github.com/ShadowShahriar/speech-services","commit_stats":null,"previous_names":["shadowshahriar/speech-services"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShadowShahriar/speech-services","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowShahriar%2Fspeech-services","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowShahriar%2Fspeech-services/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowShahriar%2Fspeech-services/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowShahriar%2Fspeech-services/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShadowShahriar","download_url":"https://codeload.github.com/ShadowShahriar/speech-services/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowShahriar%2Fspeech-services/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35050017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["language-services","microsoft-azure","speech-services"],"created_at":"2024-11-30T22:14:32.075Z","updated_at":"2026-07-02T13:41:17.054Z","avatar_url":"https://github.com/ShadowShahriar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# speech-services\n\n\u003e [!IMPORTANT]\n\u003e Recently, I started working on the **fourth generation** of [**Jenny**][BOT], a Telegram bot with a quirky personality. There were some scenarios where it needed **Speech Synthesis** to narrate summaries of the user command, **Speech Recognition**, and **Translation**. So, I opted to use **Microsoft Azure Speech and Language services** to simplify the process. This repository demonstrates how I did these using their **SDK**.\n\nThis repository primarily focused on demonstrating the use of **Speech Synthesis** and **Speech Recognition**. Demonstration of **Translation**, **Text Summarization**, **Sentiment Detection**, and **Keyphrase Extraction** was added later.\n\n**Useful Links:**\n\n-   [**Quickstart: Convert text to speech**][MS_TTS_QS]\n-   [**Quickstart: Recognize and convert speech to text**][MS_STT_QS]\n-   [**Quickstart: Recognize and translate speech to text**][MS_RST_QS]\n-   [**Quickstart: using text, document and conversation summarization**][MS_TS_QS]\n\n**Useful Nodejs Examples:**\n\n-   [**Text to Speech Quickstart Code**][EX_05]\n-   [**Speech to Text Quickstart Code**][EX_04]\n-   [**Speech Translation Quickstart Code**][EX_06]\n-   [**Text Summarization Quickstart Code**][EX_03]\n-   [**Extract Key Phrases from Alternative Document Input**][EX_02]\n-   [**Analyze Text Sentiment**][EX_01]\n\n**Samples from Official Repositories:**\n\n-   [**Microsoft Cognitive Services Speech SDK**][REPO_01] (TTS, STT, Speech Translation)\n-   [**Azure SDK for JavaScript**][REPO_02] (Text Summarization)\n\n**Playground:**\n\n-   [**Voice Gallery**][VOICE_GALLERY]\n-   [**Text Summarization**][TEXT_SUMMARIZATION]\n\n# Walk Through\n\n\u003e [!CAUTION]\n\u003e The official documentation for using these services was hard to follow. Some instructions seem confusing due to their use of **AI Language** and **Language Service** terms interchangeably. Also, there is so much information, yet everything is scattered and disorganized.\n\n\u003c!-- prettier-ignore --\u003e\n\u003e [!NOTE] \n\u003e **Speech Synthesis**, **Speech Recognition**, and **Translation** are **Speech Services** that requires the `cognitive-services-speech-sdk` NPM package. However, **Text Summarization** is a **Language Service** that requires a separate NPM package (`@azure/ai-language-text`), which, in turn, has a completely different type of API. It seems that Speech Services SDK and Language Services SDK were developed by separate developer teams with no correlation with each other's API structure.\n\n## Creating the Resources\n\n1. Sign in with your Microsoft or GitHub account and go to the [**Microsoft Azure Portal**][MS_AZURE_PORTAL].\n\n2. Create a [**Speech Resource**][RES_SPEECH] and a [**Language Resource**][RES_LANG] in the Azure Portal.\n\n3. Take notes for the **first key** (Key 1), **region** (e.g. eastus, westus) and **endpoint** for both resources. Create a `.env` file in the current directory and add the environmental variables here:\n\n    ```yaml\n    AZURE_SPEECH_SUBSCRIPTION_KEY=\u003cSPEECH FIRST KEY\u003e\n    AZURE_SPEECH_REGION=\u003cSPEECH REGION\u003e\n    AZURE_LANUAGE_ENDPOINT=\u003cLANGUAGE ENDPOINT URL\u003e\n    AZURE_LANUAGE_SUBSCRIPTION_KEY=\u003cLANGUAGE FIRST KEY\u003e\n    ```\n\n## Installing the dependencies\n\nRun the following command in the terminal:\n\n```bash\nnpm install\n```\n\nThis will install the following NPM dependencies:\n\n-   [**dotenv**][NPM_04]: Required for defining environmental variables.\n-   [**@azure/ai-language-text**][NPM_02]: Required for Text Summarization.\n-   [**@azure/ai-text-analytics**][NPM_03]: Required for Sentiment Detection and Keyphrase Extraction.\n-   [**microsoft-cognitiveservices-speech-sdk**][NPM_01]: Required for Text to Speech, Speech to Text, and Speech Translation.\n\n## Testing\n\nRun the following command in the terminal (You can also use `npm test` if you want):\n\n```bash\nnode .\n```\n\nIf everything is working as expected, it should produce the following output in the terminal:\n\n```\nWrote speech to file: test.wav\nSpoken text: Hi and thank you so much for paying a visit to this repository. It's been a pleasure to meet you.\nTranslated text: হাই এবং এই সংগ্রহস্থলটি দেখার জন্য আপনাকে অনেক ধন্যবাদ। আপনার সাথে দেখা করে খুব ভাল লাগল।\nSummary:\n[\n  'As you probably guessed, this was heavily inspired by the story and plot of \"The Greatest Showman.\"'\n]\nSentiment:\n{\n  sentiment: 'negative',\n  scores: { positive: 0, neutral: 0.03, negative: 0.97 }\n}\nKeyphrases:\n[\n  'favorite song cover', 'The Greatest Showman',\n  'best violinist',      'crazy dream',\n  'young boy',           'story',\n  'childhood',           'classmates',\n  'teachers',            'fun',\n  'Life',                'turn',\n  'stage',               'front',\n  'millions',            'people',\n  'doubters',            'wrong',\n  'passion',             'plot'\n]\n```\n\n# Methods\n\n## speak\n\n```typescript\nconst speak(text: string, talentID?: number, style?: string, wav?: boolean): Promise\u003cBuffer|false\u003e\n```\n\n| Parameter  | Description                                                                                                                                                                                                                                                                                                                                  |\n| :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `text`     | The given text that would be converted to speech.                                                                                                                                                                                                                                                                                            |\n| `talentID` | Voice ID of the speaker. It can be any integer from **0** to **6**.                                                                                                                                                                                                                                                                          |\n| `style`    | Narrative style of the given style. Accepted values are: `default`, `cheerful`, `newscast`, `empathetic`, `excited`, `unfriendly`, `friendly`, `shy`, `embarassed`, `serious`, `sad`, `relieved`, `angry`, `terrified`, `shouting`, `whispering` \u003cbr\u003e Please note that **not all voice models will support all the styles mentioned above**. |\n| `wav`      | When `true` the output format would be `wav` (PCM\u0026nbsp;48Khz\u0026nbsp;16Bit\u0026nbsp;Mono). When `false` the output format would be `opus` (OGG\u0026nbsp;48Khz\u0026nbsp;16Bit\u0026nbsp;Mono)                                                                                                                                                                     |\n\n## recognize\n\n```typescript\nconst recognize(buffer: Buffer, bengali?: boolean): Promise\u003cstring|false\u003e\n```\n\n| Parameter | Description                                               |\n| :-------- | :-------------------------------------------------------- |\n| `buffer`  | Audio buffer (e.g. `fs.readFileSync(\"test.wav\")`)         |\n| `bengali` | `true` if the speech recognition language is **Bengali**. |\n\n## translate\n\n```typescript\nconst translate(buffer: Buffer, from?: string, to?: string): Promise\u003cstring|false\u003e\n```\n\n| Parameter | Description                                       |\n| :-------- | :------------------------------------------------ |\n| `buffer`  | Audio buffer (e.g. `fs.readFileSync(\"test.wav\")`) |\n| `from`    | Speech recognition language (Default: `en-US`)    |\n| `to`      | Translation language (Default: `bn-IN`)           |\n\n## summarize\n\n```typescript\nconst summarize(text: string, length?: boolean|string|null, language?: string): Promise\u003cstring|false\u003e\n```\n\n| Parameter  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `text`     | Given long form text.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| `length`   | By default the `summarize` function would extract text from the given text, but if `length` is `true`, it will produce an **abstracted summary** of the given text. \u003cbr\u003e\u003cbr\u003e `length` can be a string (`oneSentence`, `short`, `medium`) that denotes the size of the **extractive summary**. \u003cbr\u003e\u003cbr\u003e `length` can also be any integer from **1** to **20** specifying the maximum number of sentences to be extracted in the **extractive summary**. Defaults to **3** when omitted. |\n| `language` | Language of the given text (Default: `en`)                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n\n## sentiment\n\n\u003c!-- prettier-ignore --\u003e\n```typescript\nconst sentiment: (text: string, language?: string) =\u003e Promise\u003cfalse | {\n    sentiment: \"positive\" | \"neutral\" | \"negative\";\n    scores: { positive: number, neutral: number, negative: number };\n}\u003e\n```\n\n| Parameter  | Description                              |\n| ---------- | ---------------------------------------- |\n| `text`     | Given text                               |\n| `language` | Language of the given text (Default: en) |\n\n## keyphrases\n\n```typescript\nconst keyphrases: (text: string, language?: string) =\u003e Promise\u003cfalse | string[]\u003e\n```\n\n| Parameter  | Description                              |\n| ---------- | ---------------------------------------- |\n| `text`     | Given text                               |\n| `language` | Language of the given text (Default: en) |\n\n# Language Support\n\nFor my use case, I needed support for **English** and **Bengali** languages. Here are the language codes I used for each service:\n\n| Service                   | Language Codes        |\n| ------------------------- | --------------------- |\n| Text\u0026nbsp;to\u0026nbsp;Speech  | `en-AU`,\u0026nbsp;`bn-BD` |\n| Speech\u0026nbsp;to\u0026nbsp;Text  | `en-US`,\u0026nbsp;`bn-IN` |\n| Speech\u0026nbsp;Translation   | `en-US`,\u0026nbsp;`bn-IN` |\n| Text\u0026nbsp;Summarization   | `en`                  |\n| Sentiment\u0026nbsp;Detection  | `en`,\u0026nbsp;`bn`       |\n| Keyphrase\u0026nbsp;Extraction | `en`,\u0026nbsp;`bn`       |\n\n\u003cbr\u003e\n\n**Support for other languages:**\n\n-   [**Language Support (Text to Speech)**][LS_TTS]\n-   [**Language Support (Speech to Text)**][LS_STT]\n-   [**Language Support (Speech Translation)**][LS_RST]\n-   [**Language Support (Text Summarization/Sentiment Detection/Keyphrase Extraction)**][LS_TS]\n\n# License\n\nThe source code is licensed under the [**MIT License**][LICENSE].\n\n\u003c!-- === examples === --\u003e\n\n[EX_01]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/textanalytics/ai-text-analytics/samples/v5/javascript/analyzeSentiment.js\n[EX_02]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/textanalytics/ai-text-analytics/samples/v5/javascript/alternativeDocumentInput.js\n[EX_03]: https://learn.microsoft.com/en-us/azure/ai-services/language-service/summarization/quickstart?pivots=programming-language-javascript\u0026tabs=text-summarization%2Cwindows#code-example\n[EX_04]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-to-text?tabs=windows%2Cterminal\u0026pivots=programming-language-javascript#recognize-speech-from-a-file\n[EX_05]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal\u0026pivots=programming-language-javascript#create-the-application\n[EX_06]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-translation?tabs=windows%2Cterminal\u0026pivots=programming-language-javascript#translate-speech-from-a-file\n\n\u003c!-- === links === --\u003e\n\n[MS_AZURE_PORTAL]: https://portal.azure.com/#home\n[RES_SPEECH]: https://portal.azure.com/#create/Microsoft.CognitiveServicesSpeechServices\n[RES_LANG]: https://portal.azure.com/#create/Microsoft.CognitiveServicesTextAnalytics\n[NPM_01]: https://www.npmjs.com/package/microsoft-cognitiveservices-speech-sdk\n[NPM_02]: https://www.npmjs.com/package/@azure/ai-language-text\n[NPM_03]: https://www.npmjs.com/package/@azure/ai-text-analytics\n[NPM_04]: https://www.npmjs.com/package/dotenv\n[LS_TS]: https://learn.microsoft.com/en-us/azure/ai-services/language-service/concepts/language-support\n[LS_RST]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=speech-translation\n[LS_STT]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=stt\n[LS_TTS]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=tts\n[MS_TS_QS]: https://learn.microsoft.com/en-us/azure/ai-services/language-service/summarization/quickstart?pivots=programming-language-javascript\u0026tabs=text-summarization%2Cwindows\n[MS_RST_QS]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-translation?tabs=windows%2Cterminal\u0026pivots=programming-language-javascript\n[MS_STT_QS]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-to-text?tabs=windows%2Cterminal\u0026pivots=programming-language-javascript\n[MS_TTS_QS]: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal\u0026pivots=programming-language-javascript\n[REPO_01]: https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/samples/js/node\n[REPO_02]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/textanalytics/ai-text-analytics/samples/v5/javascript\n[VOICE_GALLERY]: https://speech.azure.cn/portal/voicegallery\n[TEXT_SUMMARIZATION]: https://language.cognitive.azure.com/tryout/summarization\n[BOT]: https://t.me/jenny_the_robot\n[LICENSE]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowshahriar%2Fspeech-services","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshadowshahriar%2Fspeech-services","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowshahriar%2Fspeech-services/lists"}