{"id":13723392,"url":"https://github.com/codemillmatt/quarantine-bingo","last_synced_at":"2025-07-09T07:31:25.903Z","repository":{"id":48911065,"uuid":"259395930","full_name":"codemillmatt/quarantine-bingo","owner":"codemillmatt","description":"Xamarin.Forms bingo game that plays itself","archived":false,"fork":false,"pushed_at":"2021-07-05T23:04:49.000Z","size":418,"stargazers_count":11,"open_issues_count":7,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-14T12:51:20.031Z","etag":null,"topics":["cognitive-services","xamarin-forms"],"latest_commit_sha":null,"homepage":null,"language":"C#","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/codemillmatt.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}},"created_at":"2020-04-27T16:56:24.000Z","updated_at":"2023-03-12T16:38:21.000Z","dependencies_parsed_at":"2022-09-23T23:40:48.634Z","dependency_job_id":null,"html_url":"https://github.com/codemillmatt/quarantine-bingo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemillmatt%2Fquarantine-bingo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemillmatt%2Fquarantine-bingo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemillmatt%2Fquarantine-bingo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemillmatt%2Fquarantine-bingo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemillmatt","download_url":"https://codeload.github.com/codemillmatt/quarantine-bingo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225492617,"owners_count":17482924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cognitive-services","xamarin-forms"],"created_at":"2024-08-03T01:01:40.537Z","updated_at":"2024-11-20T08:40:20.160Z","avatar_url":"https://github.com/codemillmatt.png","language":"C#","funding_links":[],"categories":["Games"],"sub_categories":["Git"],"readme":"# Quarantine Bingo\n\n![bingo game drawing](https://res.cloudinary.com/code-mill-technologies-inc/image/upload/c_scale,h_600/v1588012752/93625_vveito.jpg)\n\nAs I write this it's April of 2020, so you know what that means... I'm stuck inside of my house. And my extended family is stuck inside of their houses too.\n\nSo to help pass the time and keep those family bonds strong ... we decided to have a weekly family game night over FaceTime and play bingo!\n\nSo I decided to write a quick app to help auto recognize bingo numbers as they're called - then tell me if I won or not.\n\n## Quarantine Bingo!\n\nSo here's what I built. It's a simple Xamarin.Forms app that displays a bingo card.\n\nI _could_ tap on the numbers as they're being called... but it's much more fun to let the iPad do it for me!\n\nAnd it tells me if I've won the game or not.\n\n![game in action](https://res.cloudinary.com/code-mill-technologies-inc/image/upload/e_shadow:40/v1588009518/ScreenFlow_glsnrg.gif)\n\nWhat's not to like?\n\n## Cognitive Services Speech to Text\n\nTo figure out what number has been called I'm using one of the lesser known [Cognitive Services - that of Speech to Text](https://docs.microsoft.com/azure/cognitive-services/speech-service/quickstarts/speech-to-text-from-microphone?WT.mc_id=quarantinebingo-github-masoucou).\n\nWhat Speech to Text does is pretty simple. It uses the microphone to listen to a stream of words, then translates those words into a string, then returns it to you. \n\n(It also does a whole lot more - the SDK has functionality to [\"listen\" for wake words](https://docs.microsoft.com/azure/cognitive-services/speech-service/how-to-choose-recognition-mode?WT.mc_id=quarantinebingo-github-masoucou) - think along the lines of Cortana!)\n\nAnd there's a free tier so I won't have to pay anything!\n\nSweet!\n\nSo all I would need to do is to write a little bit of code to \"listen\" for numbers, check if the card is displaying that number, then voila - bingo time!\n\n## Let's play bingo!\n\nThere's three parts to getting Speech to Text working.\n\n* Setup the Speech API Cognitive Service in the Azure portal\n* Install the NuGet package\n* Make some changes to the `Info.plist` and `AndroidManifest.xml` files.\n* Write the code!\n\n### Setup Azure\n\nGo to the Azure portal - then [startup the CLI](https://docs.microsoft.com/azure/cloud-shell/quickstart?view=azure-cli-latest\u0026WT.mc_id=quarantinebingo-github-masoucou). Then enter these commands:\n\n```language-bash\nRESOURCE_GROUP_NAME = \"PUT THE NAME OF YOUR RESOURCE GROUP HERE CALL IT WHATEVS\"\nSPEECH_SERVICE_NAME = \"PUT THE NAME OF YOUR SPEECH SERVICE HERE THE NAME IS YOUR CHOICE\"\n\naz cognitiveservices account create -n $SPEECH_SERVICE_NAME -g $RESOURCE_GROUP_NAME --kind SpeechServices --sku F0 -l westus\naz cognitiveservices account keys list -n $SPEECH_SERVICE_NAME -g $RESOURCE_GROUP_NAME\n```\n\n### Install the NuGet package\n\nBack into whatever Xamarin project you want to run the Speech to Text from.\n\nInstall the following NuGet: [Microsoft.CognitiveServices.Speech](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech/)\n\nIf you're doing Forms - you're gonna have to put that in the platform and the Forms projects.\n\n### Make the platform changes\n\nThere's a couple of things that you need to change on each platform project.\n\nFirst you need to tell iOS what to display when it prompts the user for access to the microphone. In to the `Info.plist`\n\nAdd the following key to it:\n\n```language-xml\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eTranscribe Bingo Cards\u003c/string\u003e\n```\n\nOver on the Droid side of things - pop open the `AndroidManifest.xml` file and add:\n\n```language-xml\n\u003cuses-permission android:name=\"android.permission.RECORD_AUDIO\" /\u003e\n```\n\nDone!\n\n### Listen and transcribe!\n\nNow you'd think this would be the difficult part. You have to prompt for the microphone permissions. Then somehow get the audio stream from the mic. Buffer all that up and send it to Azure. Rely on some kind of weird callback to get the transcribed text back... ugh.\n\nTurns out it's not too bad!\n\nPrompting for the permissions is a breeze thanks to [`Xamarin.Essentials`](https://docs.microsoft.com/xamarin/essentials/permissions?WT.mc_id=quarantinebingo-github-masoucou). It'll look something like this:\n\n```language-csharp\npublic async Task\u003cPermissionStatus\u003e CheckAndRequestMicrophonePermission()\n{\n    var status = await Permissions.CheckStatusAsync\u003cPermissions.Microphone\u003e();\n\n    if (status != PermissionStatus.Granted)\n    {\n        status = await Permissions.RequestAsync\u003cPermissions.Microphone\u003e();\n    }\n\n    return status;\n}\n```\n\nCall it before turning on the recording. If the `PermissionStatus` is anything but `Granted` then prompt the user to give the app microphone capabilities.\n\nNow the listen and transcribe part. Here's the function I'm using to start up a continuous listen and transcribe:\n\n```language-csharp\nusing Microsoft.CognitiveServices.Speech; // this is the namespace of the speech to text stuff\n\nSpeechRecognizer recognizer; // this is a class level variable\n\npublic async Task StartTranscription()\n{\n    if (recognizer == null)\n    {\n        var config = SpeechConfig.FromSubscription(\"\u003cPUT YOUR KEY HERE\u003e\", \"westus\");\n\n        recognizer = new SpeechRecognizer(config);\n\n        recognizer.Recognized += Recognizer_Recognized;\n    }\n\n    if (isRecognizing)\n        return;\n\n    await recognizer.StartContinuousRecognitionAsync();\n\n\n    isRecognizing = true;\n}\n```\n\nNotice that `recognizer.Recognized` event. That's what's gonna get called every time some text comes back.\n\nBut notice what's _not_ there... nothing about handling the mic... or handling the bytes and bytes of audio input. It's all done for you! Don't worry about it!\n\nThen finally that event where the transcribed text comes back:\n\nThe text is inside of the `SpeechRecognitionEventArgs` object that's passed in. It has a `Result.Text` property.\n\nThe text that comes back is in nice bite size chunks. In other words - it won't return tons and tons of sentences all at once. The SDK is smart enough to send audio up to Azure in small batches to help speed the processing.\n\nThere's also a little bit of bingo logic going on here. First I'm taking that string of text and then looping through each character in it - looking for numbers. \n\nThe text that comes back will be full sentences and if people are talking, the bingo numbers will be buried within.\n\nI found that any **G** bingo numbers come across as **3**. So **G56** interprets as **356**. So I'm actually looking for 3 numbers in a row - and if I find 3 then throwing that first one out.\n\n## Bingo!!\n\nThat's all there is to it. A pretty simple project that adds some really neat functionality with not a lot of code.\n\nAnd the best part - it really wows your family! 🤣\n\nSo check out the code - and expand upon it - I'd love to see what you come up with! (One suggestion - have it check for \u0026 then launch your favorite music streaming service ... that way you can have it play a victory song when you win!)\n\n**AND DON'T JUDGE MY GAME PROGRAMMING SKILLS!** I brute forced everything! \n\nMultiple arrays for each column - check the winning scenarios manually, and it's easy to trick - it's all hard-coded and brute force!! 💪\n\nAnd the user interface is U.G.L.Y - ugly!\n\nI mean - if I don't have time to play bingo properly - I don't have time to code a game properly either!!\n\n_(Seriously though - I'm just joking - of course I played ~for real~ during family game nights. The app was just a fun little way of showing off how cool Azure is to my family!)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemillmatt%2Fquarantine-bingo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemillmatt%2Fquarantine-bingo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemillmatt%2Fquarantine-bingo/lists"}