This file contains 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
def measure_max_gpu_usage(func): | |
from torch.cuda import max_memory_allocated, reset_peak_memory_stats | |
def wrapper(*args, **kwargs): | |
reset_peak_memory_stats() | |
result = func(*args, **kwargs) | |
max_memory = max_memory_allocated() / 1024 / 1024 / 1024 | |
print(f"Maximum GPU Usage: {max_memory:.3f} GB") | |
return result |
This file contains 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 os | |
import platform | |
import torch | |
def get_gpu_info(): | |
if torch.cuda.is_available(): | |
return torch.cuda.get_device_name(0) | |
else: | |
return "No CUDA-capable GPU found" |
This file contains 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
const getUrl = (uri: string): string => { | |
/** | |
* Extracts the bucket and object key from the URI and returns the URL to the object. | |
* @param uri The URI of the object. | |
* @returns The URL to the object. | |
* @example | |
* getUrl('s3://bucket-name/object-key') // 'https://bucket-name.s3.amazonaws.com/object-key' | |
* getUrl('s3://bucket-name/folder/object-key') // 'https://bucket-name.s3.amazonaws.com/folder/object-key' | |
*/ |
This file contains 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 'package:flutter/material.dart'; | |
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; | |
class InfiniteScrollableTable<T extends Object> extends StatefulWidget { | |
final Future<List<T>> Function(int) fetchPage; | |
final int pageSize; | |
final Widget Function(BuildContext, T, int) itemBuilder; | |
const InfiniteScrollableTable( |
This file contains 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 pathlib import Path | |
from pydub import AudioSegment | |
def convert_to_wav(audio_path,target_sr=32000): | |
P = Path(audio_path) | |
extension = P.suffix | |
extension = extension[1:] | |
if extension == "wav": | |
return audio_path |
This file contains 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 boto3 | |
BUCKET_NAMES = [ | |
"buckets", | |
"to", | |
"remove" | |
] | |
for bucket_name in BUCKET_NAMES: | |
s3 = boto3.resource("s3") |
This file contains 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
text.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, ''); |
This file contains 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 os | |
import re | |
if __name__ == "__main__": | |
root_dir = os.path.join("data", "audios") | |
os.chdir(root_dir) | |
files = os.listdir() | |
pattern = "(.*) \[.*\]\.[a-zA-Z0-9]*(\.wav)" | |
for file in files: |
This file contains 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 os | |
# Initial configuration to overcome '/usr/lib/libsndfile.dylib' (no such file) | |
# This configuration works when libsndfile is installed with brew. | |
os.environ["DYLD_LIBRARY_PATH"] = "/opt/homebrew/lib/" |
This file contains 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 os | |
filename, file_extension = os.path.splitext(name) |
NewerOlder