Skip to content

Instantly share code, notes, and snippets.

View sergio11's full-sized avatar
🏠
Working from home

Sergio Sánchez Sánchez sergio11

🏠
Working from home
View GitHub Profile
@sergio11
sergio11 / verify_voice_id_operator.py
Created May 15, 2024 18:36
Verify Voice ID operator
from airflow.utils.decorators import apply_defaults
import jwt
from operators.base_web3_custom_operator import BaseWeb3CustomOperator
from datetime import datetime, timedelta, timezone
class VerifyVoiceIdOperator(BaseWeb3CustomOperator):
"""
An operator to verify a user's voice ID using a Smart Contract on the Ethereum blockchain.
Inherits:
@sergio11
sergio11 / find_most_similar_voice_operator.py
Created May 15, 2024 18:24
Find Most similar voice operator
from operators.base_custom_operator import BaseCustomOperator
from airflow.utils.decorators import apply_defaults
from qdrant_client import QdrantClient
class FindMostSimilarVoiceOperator(BaseCustomOperator):
"""
Custom Airflow operator to find the most similar voice based on audio embeddings.
This operator searches for the most similar voice in a given collection using audio embeddings
generated from an input audio file. It connects to a QDrant server to perform the search.
@sergio11
sergio11 / voice_authentication_dag.py
Created May 15, 2024 18:06
Voice Authentication DAG
from datetime import datetime
from airflow import DAG
import importlib
import os
# Define default arguments for the DAG
default_args = {
'owner': 'airflow',
'start_date': datetime(2023, 1, 1),
'retries': 1,
@sergio11
sergio11 / process_result_webhook_operator.py
Created May 15, 2024 17:59
Process Result WebHook Operator DAG
from airflow.utils.decorators import apply_defaults
from operators.base_custom_operator import BaseCustomOperator
import requests
class ProcessResultWebhookOperator(BaseCustomOperator):
"""
Executes a task to process and send result data to a specified webhook.
"""
@apply_defaults
@sergio11
sergio11 / change_voice_id_verification_state_operator.py
Created May 12, 2024 13:23
VoicePassport - Change Voice Id verification state operator
from operators.base_web3_custom_operator import BaseWeb3CustomOperator
from airflow.utils.decorators import apply_defaults
class ChangeVoiceIdVerificationStateOperator(BaseWeb3CustomOperator):
"""
Operator for changing the verification state of a voice ID in a blockchain smart contract.
Inherits from BaseWeb3CustomOperator.
Args:
@sergio11
sergio11 / verify_voice_id_operator.py
Created May 12, 2024 13:22
VoicePassport - Verify Voice Id operator
from airflow.utils.decorators import apply_defaults
import jwt
from operators.base_web3_custom_operator import BaseWeb3CustomOperator
from datetime import datetime, timedelta, timezone
class VerifyVoiceIdOperator(BaseWeb3CustomOperator):
"""
An operator to verify a user's voice ID using a Smart Contract on the Ethereum blockchain.
Inherits:
@sergio11
sergio11 / register_voice_id_operator.py
Created May 12, 2024 13:22
VoicePassport - Register Voice Id Operator
from airflow.utils.decorators import apply_defaults
from operators.base_web3_custom_operator import BaseWeb3CustomOperator
class RegisterVoiceIDOperator(BaseWeb3CustomOperator):
"""
Operator for registering a voice ID in a blockchain smart contract.
Inherits from BaseWeb3CustomOperator.
Args:
@sergio11
sergio11 / find_most_similar_voice_operator.py
Created May 12, 2024 13:21
VoicePassport - Find Most similar voice operator
from operators.base_custom_operator import BaseCustomOperator
from airflow.utils.decorators import apply_defaults
from qdrant_client import QdrantClient
class FindMostSimilarVoiceOperator(BaseCustomOperator):
"""
Custom Airflow operator to find the most similar voice based on audio embeddings.
This operator searches for the most similar voice in a given collection using audio embeddings
generated from an input audio file. It connects to a QDrant server to perform the search.
@sergio11
sergio11 / qdrant_embeddings_operator.py
Created May 12, 2024 13:16
VoicePassport - QDrant Embeddings Operator
from airflow.utils.decorators import apply_defaults
from operators.base_custom_operator import BaseCustomOperator
from qdrant_client import QdrantClient, http
class QDrantEmbeddingsOperator(BaseCustomOperator):
"""
Custom Apache Airflow operator for upserting voice embeddings into the QDrant vector database.
:param qdrant_uri: The URI of the QDrant service.
:type qdrant_uri: str
@sergio11
sergio11 / generate_voice_embeddings_operator.py
Created May 12, 2024 13:16
VoicePassport - Generate Voice Embeddings Operator
from resemblyzer import preprocess_wav, VoiceEncoder
from airflow.utils.decorators import apply_defaults
from operators.base_custom_operator import BaseCustomOperator
class GenerateVoiceEmbeddingsOperator(BaseCustomOperator):
"""
Custom Airflow operator to generate voice embeddings from audio files.
This operator preprocesses an audio file, generates embeddings from the audio data,
and logs the execution details to MongoDB.