This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nucleus sampling is a technique used in large language models to control the randomness and diversity of generated text. It works by sampling from only the most likely tokens in the model’s predicted distribution. | |
The key parameters are: | |
Temperature: Controls randomness, higher values increase diversity. | |
Top-p (nucleus): The cumulative probability cutoff for token selection. Lower values mean sampling from a smaller, more top-weighted nucleus. | |
Top-k: Sample from the k most likely next tokens at each step. Lower k focuses on higher probability tokens. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import os | |
from tortoise.models.classifier import AudioMiniEncoderWithClassifierHead | |
from glob import glob | |
import io | |
import librosa | |
import plotly.express as px | |
import torch | |
import torch.nn.functional as F | |
import torchaudio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assembly AI speech to text | |
def assemblyai_stt(audio_filename): | |
with open(audio_filename , "rb") as f: | |
response = requests.post(base_url + "/upload", | |
headers=headers, | |
data=f) | |
upload_url = response.json()["upload_url"] | |
data = { | |
"audio_url": upload_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PyTube function for YouTube video | |
def save_audio(url): | |
yt = YouTube(url) | |
video = yt.streams.filter(only_audio=True).first() | |
out_file = video.download() | |
base, ext = os.path.splitext(out_file) | |
file_name = base + '.mp3' | |
try: | |
os.rename(out_file, file_name) | |
except WindowsError: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import fastai | |
from deoldify.visualize import * | |
def image_colorizer(url): | |
colorizer = get_image_colorizer(artistic=True) | |
source_url = url | |
render_factor = 35 | |
watermarked = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""Reverse SD.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at | |
https://colab.research.google.com/drive/1ci11cstH7uM9SPb6q2hb7f-IiZHYvcDq | |
""" | |
!pip install clip-interrogator==0.6.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem">{}</div>""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
import pickle | |
import numpy as np | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.naive_bayes import MultinomialNB | |
app = FastAPI() | |
# Load the Tfidf and Naive Bayes models | |
tfidf = pickle.load(open("tf_idf.pkt", "rb")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""Toxicity Classifier NLP.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at | |
https://colab.research.google.com/drive/1UUZzQgrRUcLujGxbmhE30AlQALMsYXCm | |
""" | |
# Commented out IPython magic to ensure Python compatibility. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import noisereduce as nr | |
from scipy.io import wavfile | |
# load data | |
rate, data = wavfile.read("voice_with_noise.wav") | |
# perform noise reduction | |
reduced_noise = nr.reduce_noise(y=data, sr=rate) It was originally published on https://www.apriorit.com/ |