<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Biruk Getaneh on Medium]]></title>
        <description><![CDATA[Stories by Biruk Getaneh on Medium]]></description>
        <link>https://medium.com/@birukgetaneh?source=rss-361fa5e930ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0U4m4zhaHJAVtrzgTBhzaA.jpeg</url>
            <title>Stories by Biruk Getaneh on Medium</title>
            <link>https://medium.com/@birukgetaneh?source=rss-361fa5e930ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:01:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@birukgetaneh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Scalable Data Migration from PostgreSQL to MySQL Database]]></title>
            <link>https://medium.com/@birukgetaneh/scalable-data-migration-from-postgresql-to-mysql-database-bcc25a1b9218?source=rss-361fa5e930ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc25a1b9218</guid>
            <dc:creator><![CDATA[Biruk Getaneh]]></dc:creator>
            <pubDate>Sat, 30 Jul 2022 22:05:46 GMT</pubDate>
            <atom:updated>2022-08-04T19:55:45.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*pogLb1mexkUWBYE2xseohQ.png" /><figcaption>Data migration pipeline</figcaption></figure><h3>What is Implemented</h3><p>In my previous blog <a href="https://medium.com/@birukgetaneh/data-warehouse-tech-stack-with-mysql-dbt-airflow-ae5fef7d135f">here</a>, a scalable data warehouse is implemented using PostgreSQL database as storage medium. This blog is an extension, where the data stored in PostgreSQL database will be migrated to MySQL database and the tool which handles the visualization is going to be Superset. Airflow is similarly take care of task scheduling workflow management. Redash was used to explore, query, and visualize the data; now, I’m utilizing Superset to achieve the same goals.</p><h3><strong>Tech Stack used</strong></h3><h4>PostgreSQL</h4><p>PostgreSQL is an advanced, enterprise-class open source relational database that supports both SQL (relational) and JSON (non-relational) querying. It features transactions with Atomicity, Consistency, Isolation, Durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures. It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users. It is the default database for macOS servers and is also available for Windows, Linux, FreeBSD, and OpenBSD.</p><h4><strong>MySQL</strong></h4><p>MySQL is the most popular and open-source relational database management system used to store raw and transformed data in our case.</p><h4>Superset</h4><p>Superset is a data exploration and visualization platform that is fast, lightweight, intuitive, and loaded with options that make it easy for users of all skill sets to explore and visualize their data, from simple pie charts to highly detailed deck.gl geospatial charts. It provides a wide array of beautiful visualizations which can be generated code-free to extract and present datasets. It is incubated as a project of the Apache Software Foundation and is often mentioned as an alternative to Tableau, Looker, Power BI, and other business intelligence solutions.</p><h3>The Migration Implementation</h3><p>As we discussed in the previous blog <a href="https://medium.com/@birukgetaneh/data-warehouse-tech-stack-with-mysql-dbt-airflow-ae5fef7d135f">here</a>, the raw and transformed data was stored in the PostgreSQL database. The aim of this task is to move the data from PostgreSQL to MySQL database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*vhRoPnCO7S25DH0NwDWFnQ.png" /></figure><p>First of all, by using the PostgresHook operator the data is read from the source PostgreSQL database. The result is then pushed to MySQL database by using MySqlHook operator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*peiO6yWsAvSEH91nBJsTeQ.png" /></figure><h3>Building a data visualization dashboard with Superset</h3><p>Superset is a data visualization and exploration tool by Airbnb. It provides a rich set of features for quick data slicing, dicing, and visualization. It comes with official support for helm. The Superset charts are pretty configurable and a lot of the functionality is driven within the setup here. i.e. things like Alerts, Reports and extra data source connectors. Dependencies are redis and a database, and it does provide you with an option to spin those up for you. It ends up with a bunch of pods, some of which workers other for scheduling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZYSTETJCRWsCS61bNshkA.png" /><figcaption>Dashboard using Superset</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc25a1b9218" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data warehouse Tech Stack with Postgres, dbt, and Airflow]]></title>
            <link>https://medium.com/@birukgetaneh/data-warehouse-tech-stack-with-mysql-dbt-airflow-ae5fef7d135f?source=rss-361fa5e930ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae5fef7d135f</guid>
            <dc:creator><![CDATA[Biruk Getaneh]]></dc:creator>
            <pubDate>Wed, 20 Jul 2022 20:51:28 GMT</pubDate>
            <atom:updated>2022-08-04T09:58:29.672Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>This blog is going to present you the ELT pipeline designed for a project which involves the process starting from the data extraction to presentation. ELT Pipeline refers to the process of extracting data from source systems, loading it into a Data Warehouse environment, and then transforming it using database operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZSgS93hbC_UYjCSa.png" /><figcaption>ELT pipeline</figcaption></figure><p>The workflow of this pipeline starts by reading the raw CSV data from the source into Postgress database, transform it using dbt, present the output by using Redash, and the final output then can be used by the data consumers such as BI tools, or Machine learning models. In the meantime, Airflow is used to schedule a daily job to sync the data from the source and perform the overall operations.</p><h3>Objective of the project</h3><p>A city traffic department wants to collect traffic data using swarm UAVs (drones) from a number of locations in the city and use the data collected for improving traffic flow in the city and for a number of other undisclosed projects. This project aims to develop a scalable data warehouse that will host the vehicle trajectory data extracted by analyzing footage taken by swarm drones and static roadside cameras.</p><h3>The Data used</h3><p>The data used in this project is the <a href="https://open-traffic.epfl.ch/index.php/downloads/#1600183005286-a0b8b26f-d4cd">pNEUMA</a> public dataset. pNEUMA is an open large-scale dataset of naturalistic trajectories of half a million vehicles that have been collected by a one-of-a-kind experiment by a swarm of drones in the congested downtown area of Athens, Greece. Each file for a single (area, date, time) is approximately 87MB in size.</p><h3>Tech Stack</h3><ul><li><strong>Airflow</strong>: an open-source workflow management platform which offers the ability to develop, monitor, and schedule workflows programmatically. Airflow pipelines are defined in Python, which are then converted into Directed Acyclic Graphs (DAG). Airflow offers numerous integrations with third-party tools, including the Postgres Airflow Operator and can be run locally using Docker Compose. Airflow is used in our pipeline to schedule a daily job that triggers the Postgres sync, followed by the dbt transformation.</li><li><strong>dbt (Data Build Tool): </strong>an open-source data transformation tool that relies on SQL to build production-grade data pipelines. dbt replaces the usual boilerplate DDL/DML required to transform data with simple modular SQL SELECT statements and handles dependency management. dbt provides a cloud-hosted option and a CLI, a Python API and integration with Airflow. In our pipeline, dbt applies a simple transformation on the ingested data using a SQL query.</li><li><strong>PostgreSQL: </strong>an advanced, enterprise class open source relational database that supports both SQL (relational) and JSON (non-relational) querying. I used it to store the raw and transformed data.</li><li><strong>Redash</strong>: an open source web application used to explore, query, visualize, and share data from our data sources.</li><li><strong>Docker</strong>: an open-source platform for building, deploying, and managing containerized applications</li><li><strong>Python</strong>: an object oriented programming language used to write the data extracting, loading and transforming scripts.</li></ul><h3>The Implementation</h3><h4><strong>1. Data Extraction and Loading</strong></h4><p>The <a href="https://open-traffic.epfl.ch/index.php/downloads/#1600183005286-a0b8b26f-d4cd">pNEUMA</a> dataset is used in this project which is available publicly in CSV Format. Each row of the dataset represents the data of a single vehicle. The first 10 columns in the 1st row include the columns’ name, where the first 4 columns include information about the trajectory like the unique trackID, the type of vehicle, the distance traveled in meters and the average speed of the vehicle in km/h. The last 6 columns are then repeated every 6 columns based on the time frequency. Therefore in order to make the data represented in rectangular format, it is rearranged by taking the first four rows, and iterate through the next six columns to get the proper relational form of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*GdvGL6tdKSzSXDMmQvS0hg.png" /></figure><h4>2. The Postgresql (Data Warehouse)</h4><p>A data warehouse is a central repository where information is coming from one or more data sources. It is an electronic method of organizing information in the cloud which combines a database and a supercomputer for transforming the data. Nowadays we can store data in the cloud through tools such as snowflake, but for this project I have used PostgreSQL as our data warehouse. In this scenario these are the tasks we need to perform with our data warehouse:</p><ul><li>Create a database in PostgreSQL</li><li>Create a table by specifying the data types of each columns</li><li>Import the CSV data into our Postgres warehouse</li><li>Execute SQL queries to check the data and transform it using dbt</li></ul><h4>3. The Airflow Orchestration</h4><p>An Airflow dag script that read the data, create a table, and load the extracted data into the created Postgres table is written which make use of the Postgres and Python operators. The dbt transformation dag is also maintained by the Airflow which involves dbt seed, run, test, and generate docs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3Ki_Ne0fwcyJSev_SGMcg.png" /><figcaption>The ELT DAG</figcaption></figure><h4>3. The dbt Transformation</h4><p>A python script that allows the dbt transformation models to transform the raw data is written to generate the overall vehicle’s information, such as computing the total number of vehicles in each category, average speed of the vehicle, and the total traveled distance. In addition to that, the individual vehicle information for the six vehicle types such as car, taxi, bus, motorcycle, medium, and heavy vehicles is extracted from the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bsP2Cw5x1BkEhukblHFOpQ.png" /><figcaption>dbt Lineage Graph</figcaption></figure><h4>4. <strong>Redash and Visualization</strong></h4><p>Visualization of the data using Redash is the last step of the overall process.<br>Redash instantly develop a dashboard for us where we can view these outcomes. We can pull our data by integrating PostgreSQL and Redash, and it allows us to create queries that evaluate data using a variety of criteria. You can immediately execute this query on top of the data sources. The Dashboard will then be constructed in order to produce effective visualization using a variety of charts and with more user-customizable controls. While doing this, any query can be created, saved for later use, and used as an input for a dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-DwDCcjRrpWRRP1jy84gXQ.png" /><figcaption>Redash Dashboard</figcaption></figure><h4>Summary</h4><p>I’ve learned from this data warehousing project that by combining these incredible tools in real time, we may manage to carry out such complicated tasks. The data is extracted, analyzed, and transformed using SQL queries in dbt, saved to our Postgres data warehouse, and then potentially published on Redash for sensing it. This is merely a typical illustration of how an ELT pipeline reduces overhead.</p><p><a href="https://github.com/bkget/Data-Warehousing">Here</a> is the link to the source code in GitHub.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae5fef7d135f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refund by Location Smart Contract using Ethereum Blockchain]]></title>
            <link>https://medium.com/@birukgetaneh/refund-by-location-smart-contract-using-ethereum-blockchain-a2ac58aff393?source=rss-361fa5e930ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2ac58aff393</guid>
            <dc:creator><![CDATA[Biruk Getaneh]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 14:08:19 GMT</pubDate>
            <atom:updated>2022-07-17T16:02:03.886Z</atom:updated>
            <content:encoded><![CDATA[<p>Ethereum is a global decentralized transaction-based state machine based on blockchain technology. It is best known for its native cryptocurrency, ether, or just ETH. Anyone can use it to create any secure digital technology. It has a token designed for use in the blockchain network, but it can also be used by participants to pay for blockchain work. Ethereum was created with the goal of being scalable, programmable, secure, and decentralized. It is used to build decentralized applications, a.k.a. DAPPs. These applications exist through small programs that live on the Blockchain, called smart contracts. It is the blockchain of choice for developers and businesses developing technology based on it to change the way many industries operate and how we live our lives.</p><p>Ethereum can power a number of applications offering a wide range of functions such as:</p><ul><li><em>Currency</em> — to sell and buy goods and services</li><li><em>Smart contracts</em> — a permission-less app that automatically executes when the contract’s conditions have been met</li><li><em>dApps</em> (Decentralized apps) — allow users to play games, to send money, to follow social media and more,</li><li><em>NFT’s</em> (Non-fungible tokens) — allow artists or others to sell art or other items directly to buyers using smart contracts.</li><li><em>DeFi</em> (Decentralized Finance) — helps to avoid centralized (government) control over the movement of money or other assets.</li></ul><h3><strong>How does the Ethereum Blockchain work?</strong></h3><p>Ethereum uses a blockchain network. The network is made up of nodes, computers of volunteers who mine for the coin. The nodes produce the Ether tokens, and mining creates the cryptography upon which the currency is based. Because mining is a demanding use of a computer’s resources, miners are rewarded with Ether.</p><p>Ethereum consists of several key components, such as blockchain, consensus mechanism, EVM, Ether, and others.</p><p><strong><em>Smart contracts</em></strong> are programmable agreement rules governing under what conditions money can change hands. In <a href="https://github.com/ethereumbook/ethereumbook/blob/develop/07smart-contracts-solidity.asciidoc">here</a> it is referred to as “immutable computer programs that run deterministically in the context of an Ethereum Virtual Machine as part of the Ethereum network protocol, i.e., on the decentralized Ethereum world computer”. Smart contract allows users to digitize conditions governing the relationship and interactions between the two parties involved in a transaction. Once these conditions are programmed and launched on the blockchain as smart contracts, they self-execute (that is, they initiate and complete the set of transactions that they govern, as long as the predefined conditions are met).</p><p><strong><em>The Ethereum blockchain:</em></strong> A record of Ethereum’s entire history — every transaction and smart contract call is stored in its blockchain. Ethereum is different from Bitcoin in that nodes don’t just have to verify and record transaction data, they also have to keep track of the network’s “state.” Ethereum’s state is the current information of all the applications running on top of it, including each user’s balance, all the smart contract code, where it’s all stored and any changes that are made. On each node, accounts, smart contract code and smart contract state are stored. Each user can have an account, which shows how much ether the user has to be stored on their account. Ethereum stores smart contracts, which describe the rules that need to be met for money to be unlocked and transferred, and the state of the smart contracts are stored as smart contract state.</p><p><strong><em>Consensus mechanism</em></strong>: The method for validating and recording data on the blockchain; it also helps to secure the network and is responsible for issuing new tokens into circulation. Ethereum uses the same consensus protocol as Bitcoin for validating data and adding it to the blockchain, known as proof-of-work (PoW). This involves mining nodes competing against one another using energy-intensive machines to win the right to add the next block to the blockchain. This happens roughly once every 10 minutes.</p><p><strong><em>The Ethereum Virtual Machine (EVM):</em></strong> The part of Ethereum that executes the rules of Ethereum and makes sure a submitted transaction or smart contract follows the rules. It allows developers to create smart contracts and lets nodes seamlessly interact with them. Ethereum developers write smart contracts with Solidity programming language. These smart contracts written in Solidity can be read by humans but not computers. It, therefore, has to be converted into low-level machine instructions — called opcodes, which the EVM can easily understand and execute.</p><p><strong><em>Ether</em></strong>: Ethereum’s token, which is required to make transactions and execute smart contracts on Ethereum. It is needed for doing just about anything on Ethereum, and when it’s used to execute smart contacts on the network it’s often referred to as “gas.” The amount of gas needed to pay is determined by the type of transaction you plan on executing and the number of Ethereum transactions waiting to be verified.</p><h3><strong>Ethereum Networks</strong></h3><p>Ethereum networks are environments that can be accessed for development, testing, or production use cases. The Ethereum mainnet is the primary public Ethereum production blockchain, where actual-value transactions occur on the distributed ledger.</p><p>There are a number of public testnets used by protocol developers or smart contract developers to test both protocol upgrades as well as potential smart contracts in a production-like environment before deployment to Mainnet. The following are the common Ethereum testnet:</p><ul><li><strong>Rinkebey</strong> — is a Proof-of-Authority testnet for Ethereum, originally started by the Geth team. To acquire ETH on Rinkeby, one can request it from a faucet. It is a proof-of-authority testnet for those running old versions of the Geth client, and is deprecated.</li><li><strong>Ropsten</strong> — is an Ethereum test network and is a Proof-of-Work testnet for Ethereum. To acquire ETH on Ropsten, one can mine on the network.</li><li><strong>Sepolia</strong> — is a proof-of-work testnet which is the best like-for-like representation of Ethereum.</li><li><strong>Goerli</strong> — is a proof-of-authority testnet that works across clients and is considered as an ideal testnet for application developers. Goerli will be the final testnet merged to proof-of-stake before Ethereum Mainnet is merged.</li><li><strong>Kovan</strong> — is a Proof-of-Authority testnet for Ethereum, originally started by the Parity team. It is a very old proof-of-authority testnet for those still running OpenEthereum clients. By now it is deprecated and will no longer receive protocol upgrades.</li></ul><h3><strong>How EVM works?</strong></h3><p>The Ethereum Virtual Machine (EVM) is a powerful, sandboxed virtual stack embedded within each full Ethereum node, responsible for executing contract bytecode. Contracts are typically written in higher level languages, like Solidity, then compiled to EVM bytecode.</p><p>EVM) is a computation engine which acts like a decentralized computer that has millions of executable projects. It acts as the virtual machine which is the bedrock of Ethereum’s entire operating structure. It is considered to be the part of the Ethereum that runs execution and smart contract deployment. The role of the EVM is to deploy a number of extra functionalities to the Blockchain to ensure users face limited issues on the distributed ledger. EVM allows anyone to create their own DApp and get use of the potential benefits of smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Iw_v3gee0FGkQuq" /><figcaption>The EVM is a stack-based architecture. Image source is <a href="https://ethereum.org/en/developers/docs/evm/">here</a></figcaption></figure><h3><strong>Smart Contract Security</strong></h3><p>Security is one of the most important considerations when writing smart contracts. In the field of smart contract programming, mistakes are costly and easily exploited. As with other programs, a smart contract will execute exactly what is written, which is not always what the programmer intended. Furthermore, all smart contracts are public, and any user can interact with them simply by creating a transaction. Any vulnerability can be exploited, and losses are almost always impossible to recover. It is therefore critical to follow best practices and use well-tested design patterns.This includes make the smart contract code simpler by removing complexity, reusing the code rather than reinvent the wheel (i.e., follow the DRY principle — don’t repeat yourself), making your code clear and easy to comprehend, testing everything to allow execution of the code to continue, and by getting familiarized with the security risks and antipatterns (i.e., reentrancy, vulnerability, preventive techniques, and the like).</p><h3>Problem Description</h3><p>The refund by location smart contract is aimed to be used when an employer agrees to pay an employee, for being present in a certain geographic area for a certain duration. The employee’s phone sends its GPS location to a smart contract at a certain interval. Based on the pre-agreed contract codified in an Ethereum smart contract, a cryptocurrency payment is executed when all the agreed conditions are met. If, at any point, the GPS sensor indicates that an employee is outside the range of the agreed GPS area, the contract state will be updated to indicate that it is out of compliance.</p><h3>Solution Outline</h3><p>The solution is basically constitute three components; the Employer web dApp, the smart contract, and the Employee mobile dApp.</p><p>All necessary information will be sent to the smart contract through the Employer web dApp (backend). The list of employees’ names and public addresses, the geographic area, and the payment information are all included. The backend smart contract will receive a package containing all of this information. On the other hand, after tracking is enabled utilizing the device’s gps location service, the mobile dApp installed on the employee’s smart phone will communicate the employee’s current location together with their external address at random intervals. After that, the predefined, codified agreement between the two parties will be taken into account when the smart contract handles the logic processing. It will review the terms and approve compliance with either making the full payment, a partial payment, or making no payment at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*IaNe93cPImk1BHTDRipZHg.png" /><figcaption>The Web dApp ReactJS front-end</figcaption></figure><h4>References</h4><ol><li><a href="https://preethikasireddy.medium.com/how-does-ethereum-work-anyway-22d1df506369">https://preethikasireddy.medium.com/how-does-ethereum-work-anyway-22d1df506369</a></li><li><a href="https://laurentsenta.com/articles/storage-and-dapps-on-ethereum-blockchain/">https://laurentsenta.com/articles/storage-and-dapps-on-ethereum-blockchain/</a></li><li><a href="https://www.bankrate.com/investing/what-is-ethereum/">https://www.bankrate.com/investing/what-is-ethereum/</a></li><li><a href="https://medium.com/@micheledaliessi/how-does-ethereum-work-8244b6f55297">https://medium.com/@micheledaliessi/how-does-ethereum-work-8244b6f55297</a></li><li><a href="https://github.com/ethereumbook/ethereumbook/blob/develop/09smart-contracts-security.asciidoc">https://github.com/ethereumbook/ethereumbook/blob/develop/09smart-contracts-security.asciidoc</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2ac58aff393" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speech-to-Text Data Collection with Kafka, Airflow, and Spark]]></title>
            <link>https://medium.com/@birukgetaneh/speech-to-text-data-collection-with-kafka-airflow-and-spark-19f61cb90886?source=rss-361fa5e930ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/19f61cb90886</guid>
            <dc:creator><![CDATA[Biruk Getaneh]]></dc:creator>
            <pubDate>Sat, 09 Jul 2022 14:19:32 GMT</pubDate>
            <atom:updated>2022-08-04T09:55:32.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ypqY1btBqMMGkZ4l2NHOOQ.png" /></figure><h4><strong>Abstract</strong></h4><blockquote>To build an accurate and reliable machine learning model, developing speech recognition models necessitates a massive amount of speech data. It is extremely difficult to collect or prepare these datasets for use by individual researchers, let alone organizations. The goal of this project was to create an application that would assist data collectors in exposing text data to volunteer end users and collecting the respective audio. Meanwhile, we have used the three popular Apache frameworks to alleviate the distributed nature of computing: Kafka, Airflow, and Spark.</blockquote><h4>Introduction</h4><p>The goal of these group project I am going to emphasize in this post is to create a data engineering pipeline that will allow millions of Amharic speakers to read digital texts in-app and on the web to enable them record the audio version of the transcription to collect a rich Speech-to-text dataset for Machine Learning engines. The <a href="https://github.com/IsraelAbebe/An-Amharic-News-Text-classification-Dataset/tree/main/data">Amharic news text classification dataset</a> is used for analysis of the pipeline. We have created an app which is deployed on the web to process text and audio files posted to and received from a data lake, transform them in a distributed manner, and load them into a warehouse in a suitable format to train a speech-to-text model.</p><h4><strong>Project Objective</strong></h4><p>The objective of this project is to develop a pipeline and then create a system using the three popular Apache frameworks; Kafka, Airflow, and Spark for generating, preprocessing, and storing the audio speech data for the respective text. With the help of these system we can collect a larger number of text files and ask volunteers to record audios of the text files. The result audio data will be used to develop an accurate machine learning speech recognition model for the language.</p><h4>The Pipeline</h4><p>Our pipeline presented below illustrates the typical method of data engineering: speech-to-text data collecting using Kafka, Airflow, and Spark. The system includes several phases and operations, including the frontend, the Flask backend, the kafka cluster, the airflow component, and the spark component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJMBcpQ5mI1glGclCSRN8g.png" /><figcaption>Architectural design of the system</figcaption></figure><p>The overall workflow of the system architecture represented on the above diagram is started on the frontend users. Users can send requests for text transcription and an audio through the front end, which they can interact with. The Javascript function is used to send the request to the API. The API responds to a consumer’s request for untranscribed text in the Kafka Cluster, retrieves the overall data upon receipt of the user’s request, and sends individual data items to the front-end until the entire dataset has been fetched. Then, the audio data with untranscribed text is saved in an S3 bucket, and the references are sent to Kafka as topics.</p><p>The data streaming between the API and Airflow is managed by the Kafka cluster. It would gather information from the front end and send it to the S3 bucket storage to be processed later. The Airflow component queues the audio data that has been transcribed and sends it to storage (S3 bucket). Untranscribed text is read by the Airflow flow, stored in an S3 bucket, and processed text audio is sent to a Kafka cluster. The audio data is preprocessed using the spark component. The transcription of the audio is cross-checked against it. The data is saved to the S3 bucket if the audio and transcription are accurate.</p><p>The major reason why we selected this way of end to end data engineering pipeline is because it is flexible and robust. And most of all easy for speech-to-text machine learning engines to subscribe to a topic and retrieve a message, which is exactly what we are trying to achieve in this data engineering pipeline.</p><h4>Technologies used to build the data capture pipeline</h4><p>Apache Kafka, Airflow, and Spark are open-source task management platforms that help companies create seamlessly functioning workflows to organize, execute and monitor their tasks. Apache Kafka provides users with a framework to store, read, and analyze streaming data. Airflow allows users to automate tasks with the help of scripts. It makes use of a scheduler that helps execute numerous jobs with the help of an array of workers while following a set of specified dependencies. Spark on the other hand provides a faster and more general data processing platform .</p><p>In our situation, Kafka is utilized to store the unprocessed audio text in a reliable and fault-tolerant manner. It offers a uniform, low-latency, high-throughput platform that is horizontally scalable. Because Kafka Streams is a very recent and quick, lightweight stream processing solution that performs best if all of your data intake is coming through Apache Kafka, we are very interested in applying it to our system. Additionally, Kafka permits the producer to communicate with each consumer one-on-one in private sessions, and allows consumers to read the information as it was being created by producers. In this project, streams of audio text records are published and subscribed to, using the Kafka system. The audio producer publishes data to the Kafka topics. Customers that use text messaging can subscribe to topics and receive messages. The waiting message or the dictation could be the message from the Kafka topics.</p><p>Since Airflow is used to manage the process in data engineering pipelines, we can use it to add alerting to the pipelines, perform various data quality and integrity checks, and keep an eye on the workflow. It can be used to simultaneously schedule jobs for the Kafka cluster and the Spark engine. It is a great tool for streamlining workflow organization, execution, and monitoring. With this, we have scheduled jobs like untranscribed text publishing, unprocessed text audio processing, untranscribed text data saving, and untranscribed text publishing using the Airflow. When the customer subscribes to the subjects of the processed audio text publishers Airflow schedule for the Kafka cluster. Receiving unprocessed text audio that is given by the producer, it schedules its storage and delivery of untranscribed text publishing to kafka cluster and unprocessed text audio processing to spark.</p><p>Spark is used for big data workloads, for fast queries against any size of data. It leverages in-memory caching and efficient query execution. In a word, Spark is a quick and all-purpose engine for big data processing. Spark processes large amounts of data quickly. The most versatile, well-liked, and often utilized stream processing solution is by far Spark. Spark, version 2.3.0, has been improved from micro batch processing to continuous streaming mode. For this reason, we loaded, processed, and transformed audio data streams using the spark with airflow scheduler.</p><h4>Data Exploratory Analysis</h4><p>The <a href="https://github.com/IsraelAbebe/An-Amharic-News-Text-classification-Dataset/tree/main/data">Amharic news text classification dataset</a> is used in this work for analyzing the pipeline workflow. The dataset is primarily used as a source of transcription text, which will then be displayed to frontend application users in order for them to obtain the audio recorded equivalence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7s6PljJzH_RyFmpoLC_OA.png" /></figure><p>The dataset contains various news data collected from various sources, with the goal of classifying Amharic news using machine learning classifiers. The data was obtained from a GitHub user named <a href="https://github.com/IsraelAbebe/An-Amharic-News-Text-classification-Dataset/tree/main/data">Israel Abebe</a> and consists of six columns: headline, category, data, views, article, and link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9MiQmzu674Nz02M7XQUkg.png" /></figure><p>Since our goal is to extract sentences for our audio data collection system, we only took two fields from this dataset: text category and article. The reason for choosing these fields is that the sentences in the other fields are inappropriate for our needs, and we can get a number of sentences from a single article by segmenting it with sentence end marks. For each article, we have six defined possibilities of text category as shown in the following bar plot diagram; sport, politics, business, entertainment, national, and international news.</p><p>While attempting to preprocess the data, we discovered that there are no missing values and that all of the fields contain only string object type data. We segmented out and took texts that included less than 15 words associated with their category to get precise sentences that fit our requirements. Following that, we saved our transcription text data in our project data folder for the upcoming processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*y7_I3Jskbt8HN98A" /><figcaption>Distribution of text category</figcaption></figure><h4>What is Implemented?</h4><p>We began our implementation with the system’s front-end. This was a react-based user interface with which the users would interact. It would allow the user to retrieve a sentence, skip to the next sentence, record an audio, listen to the audio, clear and re-record the audio, and finally send the audio and sentence to the backend. All of these features were built with the ReactJS front-end framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D3dJ-HAB4EGzRMdx-EYWZA.png" /><figcaption>Front end application</figcaption></figure><p>The front-end communicates with the Flask back-end API. The front-end receives new sentences from this API and also sends text-audio pairs. In addition to the front-end, this API communicates with a Kafka instance, which serves as our system’s central bus. When a front-end request arrives, the back-end consumes one message from a Kafka topic. That single message is a sentence that has already been published on the subject. The message is then sent to the front-end by the back-end. Because it sends the text-audio pairs it receives from the front end to another Kafka topic, the API also serves as a publisher client.</p><p>We use a dockerized version of Kafka. There are two zookeeper instances and two brokers in our current configurations. Everything else is interacting with the brokers’ exposed ports. The docker-compose file we’re using also launches kafdrop, a Kafka visualization webapp. This enables us to have an easy-to-use interface for checking the status of our Kafka instance. This includes checking to see if messages have been published on the topics, determining whether the brokers are operational, determining when new messages arrive, and so on.</p><p>The spark jobs that clean and validate the audio in the text-audio pairs are another component. Airflow is used to start the spark job. The spark component first receives a list of audio text pairs and loads them into a spark dataframe before distributing them among various spark clusters. We remove long silences in the audio clips first, followed by any noise. Finally, the cleaned audio text pairs are saved in an Amazon S3 bucket.</p><h4>Lessons Learned</h4><p>In doing this project, I have learned how to create and configure Apache Kafka clusters, how to publish and subscribe to streams of records, how to store streams of records in a fault-tolerant durable way, and most importantly how to process them as they occur. I have also learned how to work with Apache Airflow for workflow orchestration and Apache Spark to load and transform the data we have.</p><h4>Future Plans</h4><p>Creating a reliable and fault-tolerant pipeline for storing speech and text can pave the way for training an effective Machine Learning Model. In this project, we were able to collect text and audio files in Amharic and store them in an S3 bucket. There are currently insufficient audios and transcripts for the Amharic language to develop an accurate machine learning speech recognition model.</p><p>Taking this into consideration, we can collect a larger number of text files and ask volunteers to record audios of those text files. As a result, the collected data will be saved in an S3 bucket and will be ready to be trained into a model.<br>Another issue is that our front-end can access the text via the flask API, which accesses the kafka consumer, but when it does so, we want it to access a text randomly from the kafka cluster. We intend to make this possible in the future.</p><p>The implementation of this project is found in this <a href="https://github.com/bkget/STT-Data-Collection">GitHub</a> link.</p><h4>References</h4><ul><li><a href="https://acloudguru.com/hands-on-labs/installing-a-kafka-cluster-and-creating-a-topic">Installing a Kafka Cluster and Creating a Topic — Hands-on Labs | A Cloud Guru</a></li><li><a href="https://cloudblogs.microsoft.com/opensource/2018/07/09/how-to-data-processing-apache-kafka-spark/">How to process streams of data with Apache Kafka and Spark (microsoft.com)</a></li><li><a href="https://medium.com/vantageai/keeping-your-ml-model-in-shape-with-kafka-airflow-and-mlflow-143d20024ba6">Keeping your ML model in shape with Kafka, Airflow and MLFlow | by Mike Kraus | VantageAI | Medium</a></li><li><a href="https://towardsdatascience.com/why-apache-airflow-is-a-great-choice-for-managing-data-pipelines-48effcce3e41">Why Apache Airflow Is a Great Choice for Managing Data Pipelines | by Kartik Khare | Towards Data Science</a></li><li><a href="https://dev.to/florimondmanca/breaking-news-everything-is-an-event-streams-kafka-and-you-2n9j">Breaking News: Everything Is An Event! (Streams, Kafka And You) — DEV Community</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19f61cb90886" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amharic and Swahili language Speech Recognition — Speech-to-Text]]></title>
            <link>https://medium.com/@birukgetaneh/amharic-and-swahili-language-speech-recognition-speech-to-text-257e00a317b6?source=rss-361fa5e930ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/257e00a317b6</guid>
            <dc:creator><![CDATA[Biruk Getaneh]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 17:46:25 GMT</pubDate>
            <atom:updated>2022-07-17T16:14:34.758Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Amharic and Swahili Language Speech Recognition — Speech-to-Text</strong></h3><blockquote>This post discusses about the development of Speech Recognition model which aims to transcribe the Amharic and Swahili language audios. From the dataset that we were given we showed that for a period of 6 hours, we achieve a WER of 18%. This is a good score and is the model that we saved and used for the purposes of performing the predictions.</blockquote><h4><strong>Motivation</strong></h4><p>The World Food Program intends to use an intelligent form to collect nutritional information about food purchased and sold at markets in two African countries: Ethiopia and Kenya. The intelligent form’s design requires selected people to install an app on their mobile phone, and whenever they buy food, they use their voice to activate the app, which registers the list of items they just bought in their own language. The app’s intelligent systems are expected to live to transcribe speech-to-text and organize information in an easy-to-process database.</p><p>There are many matured speech recognition systems available, such as Google Assistant, Amazon Alexa, and Apple’s Siri. However, all of those voice assistants work for limited languages only.</p><h4>Objective of the Project</h4><p>The general objective of this project is to develop a deep learning model to transcribe Amharic and Swahili audio data into text. Inline with this general objective the following specific objectives are also considered.</p><ul><li>To load and describe the Amharic and Swahili <a href="https://github.com/getalp/ALFFA_PUBLIC">ALFFA_PUBLIC</a> training and testing dataset</li><li>To apply different preprocessing techniques and clean both the audio and text data</li><li>To design and develop a deep learning model that can transcribe the speech to text</li><li>To evaluate the model using Word Error Rate (WER)</li></ul><h4><strong>Review of Previous Works</strong></h4><p>Yonas Woldemariam in [1], adopted a transfer learning approach for a less-resourced Amharic language in order to solve resource scarcity problems in speech recognition development and improve the model performance. During the experiment, the author transferred acoustic models trained on two different source languages, i.e., English and Mandarin, to Amharic. Prior to the transfer learning process, the author performed feature dimension matching between the source and target languages, as well as alignment of the splicing settings that determine the content size of concatenated speech segments. The reported experimental results show that transferring the hidden layers of the trained source language neural networks resulted in a significant WER (Word Error Rate) reduction. The Amharic ASR model adapted from English yields the best WER reduction from 38.72 percent to 24.50 percent in the best-case scenario.</p><p>Das, A. <em>et.al., </em>in [2] developed an automatic speech recognition system for three Sub-Saharan African languages, Amharic, Swahili, and Dinka, using probabilistic transcriptions collected from crowd workers who do not speak or are familiar with the African languages According to the authors, utterances spoken in African languages caused a language mismatch, causing the transcription to prune to label inaccuracies. During their experiment, they used a mismatched crowdsourcing technique that converts raw crowd transcriptions to confusion networks. Using probabilistic transcriptions of African languages, the authors adapted multilingual hidden Markov models (HMM) and deep neural network (DNN) models. They reported that the probabilistic Deep Neural Network provides a low absolute phone error rate ranging from 6.56% to 18.14%.</p><p>Tilaye Alemu, the author of <a href="http://ainsightful.com/index.php/2018/11/27/deep-learning-for-amharic-speech-recognition/">this</a> article [4], used a Deep Recurrent Network to train an Amharic speech recognizer. He prefers the MFCC audio feature over the Spectrogram because it has fewer features relative to Spectrogram and requires less training data. The parameters of the Neural Network were randomly initialized during the training process. The training data is then passed through the designed acoustic model, which employs the CTC loss, making minor adjustments to the parameters at each step to generate the transcription for the given audio data.</p><h4><strong>Data and Preprocessing Techniques Used in the Analysis</strong></h4><p>The <a href="https://github.com/getalp/ALFFA_PUBLIC">ALFFA_PUBLIC</a> dataset is used in this project for model training, validation, and testing. The data contains approximately 11k audio clips totaling approximately 18 hours of Amharic speech. Each audio clip is a few seconds long and comes with a transcription.</p><p>Data preprocessing is one of the most important stage to develop an effective speech recognition system. We have started our preprocessing process by cleaning the transcription text data. Both the training and testing dataset had a problem of proper text presentation where most words are split into two, three, and more parts. Therefore, to reduce this problem we have used an Amharic dictionary for comparison of each word in our transcription data and rearrange the text representation. While in the case of the audio preprocessing, we have followed a number of processes.</p><p>The given audio dataset items have different channels, sampling rates, and size variations. All those dimension variations need to be preprocessed because deep learning models expect all our input items to have a consistent look to make it learn better [3]. First, we have converted the mono channeled audios to stereo by duplicating the first channel to the second. After that we have standardized the sampling rate by converting all audios to the same sampling rate of 44,100Hz, which is better because by choosing a higher frequency we reduce outliers. The next step was augmenting the dataset by time shifting to the right with a smaller factor (sample rate/10) data augmentation technique to add more variety to our input data and help the model learn to generalize to a wider range of inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*-1k3K7uAL1-0GxEHLmwWZg.png" /><figcaption>Data augmentation</figcaption></figure><h4><strong>Feature Extraction and Acoustic Data Modeling</strong></h4><p>The extraction of features from data is the key to any machine learning method. Data is represented by features, which are used as input into the model. We have conducted a feature extraction by examining the Mel-spectrograms and Mel-Frequency Cepstral Coefficients (MFCCs). The raw audios are converted to Mel Spectrograms to represent the signal strength, or “loudness”, of a signal over time at various frequencies present in a particular waveform. Whereas, using MFCC helps us to concisely describe the overall shape of a spectral envelope by modeling the characteristics of the human voice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*SiVhW5G5iRO1QW450xa6IQ.png" /><figcaption>Spectrogram plot — The vertical axis shows frequencies (from 0 to 8kHz), and the horizontal axis shows the time of the clip.</figcaption></figure><p>After features are extracted, these vectors are passed to acoustic models. An acoustic model attempts to map the audio signal to the basic units of speech such as phonemes or graphemes. We have extracted chroma_stft, spec_cent,spec_bw, rolloff, zcr, and mfcc audio features to perform our acoustic modeling.</p><h4><strong>MLOPs Setup</strong></h4><p>MLOps is a ML engineering culture and practice that aims to unify ML system development (Dev) and ML system operation (Ops). Using MLOps means advocating for automation and monitoring at all stages of ML system development, such as integration, testing, releasing, deployment, and infrastructure management. In this project we have applied MLOPs to track our models metrics and parameters such as, training loss, validation loss, and learning rate using mlflow.tensorflow.autolog().</p><h4><strong>The Deep Learning Architecture</strong></h4><p>Our deep learning modeling process started with loading the raw audio data in the form of a wave file. Following all the preprocessing steps discussed above, all audio wave files are converted into its corresponding spectrogram, and MFCC feature values. Those values are feed to our CNN architecture to be processed and extract feature maps that are an encoded representation of the spectrogram image. This data pass through the convolution layers with a kernel and on the last layer the Softmax activation function map the probabilities of each character that can be placed in the transcription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*vT2JAHtLKzEkfa1Q5SwD0g.png" /><figcaption>The pipeline designs our architecture followed [3]</figcaption></figure><p>The Bidirectional LSTM model processes the feature maps as a series of distinct timesteps or ‘frames’ that correspond to the desired sequence of output characters. In other words, it converts continuous feature maps into discrete representations of the audio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*v793F06enw_tIy1MNIYYvg.png" /><figcaption>CNN-RNN Model Architecture</figcaption></figure><h4>Loss Function</h4><p>CNN plus RNN-based architecture used the Connectionist Temporal Classification (CTC) algorithm to train the networks in speech recognition to determine how the characters in the transcript align with the audio <a href="https://ieeexplore.ieee.org/document/8748399">[5]</a>, and predict the speech transcript. The Loss is computed as the probability of the network predicting the correct sequence. To do this, the algorithm lists out all possible sequences the network can predict, and from that it selects the subset that match the target transcript.</p><h4>Reducing Bias</h4><p>Its known that it is difficult to eliminate bias and developing a perfect fair model for such tasks. But, to reduce the bias we have tried to choose the correct learning model by going through robust data preprocessing, performance comparison among different models, and monitor their performance.</p><h4>Result</h4><p>We used Word Error Rate (WER) evaluation metrics, to evaluate how well the model performs. By using WER we compared the predicted output and the target transcript, word by word (or character by character) to figure out the number of differences. After training our model for 50 epochs, the word error rate reduced from 1.00 to 0.18 all the way down from the first epoch to the last epoch. In the following table, the word error rate and the loss within five epoch intervals are shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*FThXal5Fyj0odFPQWOjE6w.png" /></figure><h4>Demo (Swahili Speech-to-Text Conversion)</h4><p><a href="https://eastafricanlp.herokuapp.com/">React App (eastafricanlp.herokuapp.com)</a></p><h4>Conclusion</h4><p>From our training using RNN and CNN model a word error rate 0.18 is achieved for Swahili audio transcription. But to get a better result it needs to be trained for a longer time because there is no way we can keep doing this with every single piece of dataset, it will gradually become expensive and that is why we need to create a language model for this.</p><h4>References</h4><p>[1] Yonas Woldemariam. (2020, May). Transfer learning for less-resourced Semitic languages speech recognition: the case of Amharic. In <em>Proceedings of the 1st joint workshop on spoken language technologies for under-resourced languages (SLTU) and collaboration and computing for under-resourced languages (CCURL)</em> (pp. 61–69).</p><p>[2] Das, A., Jyothi, P., &amp; Hasegawa-Johnson, M. (2016). Automatic Speech Recognition Using Probabilistic Transcriptions in Swahili, Amharic, and Dinka. In <em>INTERSPEECH</em> (pp. 3524–3528).</p><p>[3] Ketan Doshi. (Mar 25, 2021). Audio Deep Learning Made Simple: <a href="https://towardsdatascience.com/audio-deep-learning-made-simple-automatic-speech-recognition-asr-how-it-works-716cfce4c706">Automatic Speech Recognition (ASR), How it Works | by Ketan Doshi | Towards Data Science</a>, Medium post.</p><p>[4] Tilaye Alemu, (2020, March 29). <a href="http://ainsightful.com/index.php/2018/11/27/deep-learning-for-amharic-speech-recognition/">Deep Learning for Amharic speech recognition</a>, ainsightful post.</p><p>[5] Kumar, A., Verma, S., &amp; Mangla, H. (2018, October). A survey of deep learning techniques in speech recognition. In 2018 International Conference on Advances in Computing, Communication Control and Networking (ICACCCN) (pp. 179–185). IEEE.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=257e00a317b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>