Spaces:
Runtime error
Runtime error
[ | |
{ | |
"label": "APIRouter", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "UploadFile", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "File", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "Body", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "HTTPException", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "status", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "APIRouter", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "APIRouter", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "FastAPI", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "Request", | |
"importPath": "fastapi", | |
"description": "fastapi", | |
"isExtraImport": true, | |
"detail": "fastapi", | |
"documentation": {} | |
}, | |
{ | |
"label": "JSONResponse", | |
"importPath": "fastapi.responses", | |
"description": "fastapi.responses", | |
"isExtraImport": true, | |
"detail": "fastapi.responses", | |
"documentation": {} | |
}, | |
{ | |
"label": "HTMLResponse", | |
"importPath": "fastapi.responses", | |
"description": "fastapi.responses", | |
"isExtraImport": true, | |
"detail": "fastapi.responses", | |
"documentation": {} | |
}, | |
{ | |
"label": "Annotated", | |
"importPath": "typing", | |
"description": "typing", | |
"isExtraImport": true, | |
"detail": "typing", | |
"documentation": {} | |
}, | |
{ | |
"label": "time", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "time", | |
"description": "time", | |
"detail": "time", | |
"documentation": {} | |
}, | |
{ | |
"label": "os", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "os", | |
"description": "os", | |
"detail": "os", | |
"documentation": {} | |
}, | |
{ | |
"label": "get_transcription", | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"isExtraImport": true, | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "match", | |
"importPath": "app.matcher", | |
"description": "app.matcher", | |
"isExtraImport": true, | |
"detail": "app.matcher", | |
"documentation": {} | |
}, | |
{ | |
"label": "mfcc_similarty_check", | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"isExtraImport": true, | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "voice_router", | |
"importPath": "app.routers.V1.voice", | |
"description": "app.routers.V1.voice", | |
"isExtraImport": true, | |
"detail": "app.routers.V1.voice", | |
"documentation": {} | |
}, | |
{ | |
"label": "v1_routers", | |
"importPath": "app.routers.V1", | |
"description": "app.routers.V1", | |
"isExtraImport": true, | |
"detail": "app.routers.V1", | |
"documentation": {} | |
}, | |
{ | |
"label": "StaticFiles", | |
"importPath": "fastapi.staticfiles", | |
"description": "fastapi.staticfiles", | |
"isExtraImport": true, | |
"detail": "fastapi.staticfiles", | |
"documentation": {} | |
}, | |
{ | |
"label": "Jinja2Templates", | |
"importPath": "fastapi.templating", | |
"description": "fastapi.templating", | |
"isExtraImport": true, | |
"detail": "fastapi.templating", | |
"documentation": {} | |
}, | |
{ | |
"label": "CORSMiddleware", | |
"importPath": "fastapi.middleware.cors", | |
"description": "fastapi.middleware.cors", | |
"isExtraImport": true, | |
"detail": "fastapi.middleware.cors", | |
"documentation": {} | |
}, | |
{ | |
"label": "routes", | |
"importPath": "app.routers", | |
"description": "app.routers", | |
"isExtraImport": true, | |
"detail": "app.routers", | |
"documentation": {} | |
}, | |
{ | |
"label": "difflib", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "difflib", | |
"description": "difflib", | |
"detail": "difflib", | |
"documentation": {} | |
}, | |
{ | |
"label": "fuzz", | |
"importPath": "fuzzywuzzy", | |
"description": "fuzzywuzzy", | |
"isExtraImport": true, | |
"detail": "fuzzywuzzy", | |
"documentation": {} | |
}, | |
{ | |
"label": "librosa", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "librosa", | |
"description": "librosa", | |
"detail": "librosa", | |
"documentation": {} | |
}, | |
{ | |
"label": "AutoFeatureExtractor", | |
"importPath": "transformers", | |
"description": "transformers", | |
"isExtraImport": true, | |
"detail": "transformers", | |
"documentation": {} | |
}, | |
{ | |
"label": "Wav2Vec2BertModel", | |
"importPath": "transformers", | |
"description": "transformers", | |
"isExtraImport": true, | |
"detail": "transformers", | |
"documentation": {} | |
}, | |
{ | |
"label": "AutoModelForSpeechSeq2Seq", | |
"importPath": "transformers", | |
"description": "transformers", | |
"isExtraImport": true, | |
"detail": "transformers", | |
"documentation": {} | |
}, | |
{ | |
"label": "AutoProcessor", | |
"importPath": "transformers", | |
"description": "transformers", | |
"isExtraImport": true, | |
"detail": "transformers", | |
"documentation": {} | |
}, | |
{ | |
"label": "pipeline", | |
"importPath": "transformers", | |
"description": "transformers", | |
"isExtraImport": true, | |
"detail": "transformers", | |
"documentation": {} | |
}, | |
{ | |
"label": "soundfile", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "soundfile", | |
"description": "soundfile", | |
"detail": "soundfile", | |
"documentation": {} | |
}, | |
{ | |
"label": "cosine_similarity", | |
"importPath": "sklearn.metrics.pairwise", | |
"description": "sklearn.metrics.pairwise", | |
"isExtraImport": true, | |
"detail": "sklearn.metrics.pairwise", | |
"documentation": {} | |
}, | |
{ | |
"label": "numpy", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "numpy", | |
"description": "numpy", | |
"detail": "numpy", | |
"documentation": {} | |
}, | |
{ | |
"label": "torch", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "torch", | |
"description": "torch", | |
"detail": "torch", | |
"documentation": {} | |
}, | |
{ | |
"label": "load_dataset", | |
"importPath": "datasets", | |
"description": "datasets", | |
"isExtraImport": true, | |
"detail": "datasets", | |
"documentation": {} | |
}, | |
{ | |
"label": "annotations", | |
"importPath": "__future__", | |
"description": "__future__", | |
"isExtraImport": true, | |
"detail": "__future__", | |
"documentation": {} | |
}, | |
{ | |
"label": "site", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "site", | |
"description": "site", | |
"detail": "site", | |
"documentation": {} | |
}, | |
{ | |
"label": "sys", | |
"kind": 6, | |
"isExtraImport": true, | |
"importPath": "sys", | |
"description": "sys", | |
"detail": "sys", | |
"documentation": {} | |
}, | |
{ | |
"label": "router", | |
"kind": 5, | |
"importPath": "app.routers.V1.voice.voice_router", | |
"description": "app.routers.V1.voice.voice_router", | |
"peekOfCode": "router = APIRouter(prefix=\"/voice\", tags=[\"Voice\"])\[email protected](\"/transcribe\")\nasync def transcribe_audio(\n file: Annotated[UploadFile, File()], matcher_text: Annotated[str, Body()]\n):\n try:\n # Validate file type\n if not file.filename.endswith(\".wav\"):\n raise HTTPException(\n status_code=status.HTTP_400_BAD_REQUEST,", | |
"detail": "app.routers.V1.voice.voice_router", | |
"documentation": {} | |
}, | |
{ | |
"label": "router", | |
"kind": 5, | |
"importPath": "app.routers.V1.v1_routers", | |
"description": "app.routers.V1.v1_routers", | |
"peekOfCode": "router = APIRouter()\n\"\"\" include auth routes \"\"\"\nrouter.include_router(voice_router.router)", | |
"detail": "app.routers.V1.v1_routers", | |
"documentation": {} | |
}, | |
{ | |
"label": "router", | |
"kind": 5, | |
"importPath": "app.routers.routes", | |
"description": "app.routers.routes", | |
"peekOfCode": "router = APIRouter()\n\"\"\" include the v1 routes here \"\"\"\nrouter.include_router(v1_routers.router)", | |
"detail": "app.routers.routes", | |
"documentation": {} | |
}, | |
{ | |
"label": "app", | |
"kind": 5, | |
"importPath": "app.main", | |
"description": "app.main", | |
"peekOfCode": "app = FastAPI(\n title=\"Mother Tongue Voice Matcher\",\n version=\"0.0.5\",\n servers=[{\n \"url\": \"http://127.0.0.1:8000/api/v1\", \"description\": \"Local Server\"\n }],\n root_path=\"/api/v1\",\n root_path_in_servers=False,\n)\n# cors policy", | |
"detail": "app.main", | |
"documentation": {} | |
}, | |
{ | |
"label": "origins", | |
"kind": 5, | |
"importPath": "app.main", | |
"description": "app.main", | |
"peekOfCode": "origins = [\n \"http://localhost\",\n \"http://localhost:8080\",\n \"http://localhost:3000\",\n \"http://localhost:5173\",\n \"http://127.0.0.1\",\n \"http://127.0.0.1:8080\",\n \"http://127.0.0.1:3000\",\n \"http://127.0.0.1:5173\",\n]", | |
"detail": "app.main", | |
"documentation": {} | |
}, | |
{ | |
"label": "templates", | |
"kind": 5, | |
"importPath": "app.main", | |
"description": "app.main", | |
"peekOfCode": "templates = Jinja2Templates(directory=\"app/templates\")\[email protected](\"/\", response_class=HTMLResponse, include_in_schema=False)\nasync def root(request: Request):\n \"\"\"set the root to show a html welcome page\"\"\"\n return templates.TemplateResponse(request=request, name=\"index.html\")\n# include all the other api endpoints\napp.include_router(routes.router)", | |
"detail": "app.main", | |
"documentation": {} | |
}, | |
{ | |
"label": "phonetic_match", | |
"kind": 2, | |
"importPath": "app.matcher", | |
"description": "app.matcher", | |
"peekOfCode": "def phonetic_match(word1, word2):\n \"\"\"\n Compares two words based on their phonetic similarity.\n \"\"\"\n return fuzz.ratio(word1, word2)\n# Custom sequence matching function\ndef sequence_match(a, b):\n \"\"\"\n Uses sequence matching to compare two sequences of words.\n \"\"\"", | |
"detail": "app.matcher", | |
"documentation": {} | |
}, | |
{ | |
"label": "sequence_match", | |
"kind": 2, | |
"importPath": "app.matcher", | |
"description": "app.matcher", | |
"peekOfCode": "def sequence_match(a, b):\n \"\"\"\n Uses sequence matching to compare two sequences of words.\n \"\"\"\n return difflib.SequenceMatcher(None, a, b).ratio()\n# Main function to compare texts with percentage match\ndef compare_texts(text1, text2):\n \"\"\"\n Compares two texts using phonetic matching and sequence matching,\n returning a percentage match score.", | |
"detail": "app.matcher", | |
"documentation": {} | |
}, | |
{ | |
"label": "compare_texts", | |
"kind": 2, | |
"importPath": "app.matcher", | |
"description": "app.matcher", | |
"peekOfCode": "def compare_texts(text1, text2):\n \"\"\"\n Compares two texts using phonetic matching and sequence matching,\n returning a percentage match score.\n \"\"\"\n words1 = text1.lower().split()\n words2 = text2.lower().split()\n total_matches = len(words1)\n mismatches = 0\n for word1, word2 in zip(words1, words2):", | |
"detail": "app.matcher", | |
"documentation": {} | |
}, | |
{ | |
"label": "match", | |
"kind": 2, | |
"importPath": "app.matcher", | |
"description": "app.matcher", | |
"peekOfCode": "def match(original, transcription):\n return compare_texts(original, transcription)", | |
"detail": "app.matcher", | |
"documentation": {} | |
}, | |
{ | |
"label": "load_and_resample_audio", | |
"kind": 2, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "def load_and_resample_audio(file_path, target_sample_rate=16000):\n audio_input, sample_rate = sf.read(file_path)\n if sample_rate != target_sample_rate:\n audio_input = librosa.resample(\n audio_input, orig_sr=sample_rate, target_sr=target_sample_rate\n )\n return audio_input, sample_rate\ndef calculate_mfcc(audio_data, sample_rate):\n mfccs = librosa.feature.mfcc(y=audio_data, sr=sample_rate)\n mfccs_scaled = np.mean(mfccs.T, axis=0) # Average across time dimension", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "calculate_mfcc", | |
"kind": 2, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "def calculate_mfcc(audio_data, sample_rate):\n mfccs = librosa.feature.mfcc(y=audio_data, sr=sample_rate)\n mfccs_scaled = np.mean(mfccs.T, axis=0) # Average across time dimension\n return mfccs_scaled\ndef calculate_similarity(mfccs1, mfccs2):\n similarity = cosine_similarity(\n mfccs1.reshape(1, -1), mfccs2.reshape(1, -1))\n return similarity[0][0]\ndef mfcc_similarty_check(original: str, recorded: str):\n correct_pronunciation_audio, _ = load_and_resample_audio(original)", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "calculate_similarity", | |
"kind": 2, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "def calculate_similarity(mfccs1, mfccs2):\n similarity = cosine_similarity(\n mfccs1.reshape(1, -1), mfccs2.reshape(1, -1))\n return similarity[0][0]\ndef mfcc_similarty_check(original: str, recorded: str):\n correct_pronunciation_audio, _ = load_and_resample_audio(original)\n user_pronunciation_audio, sample_rate = load_and_resample_audio(recorded)\n # Extract MFCCs from audio data\n correct_mfccs = calculate_mfcc(correct_pronunciation_audio, sample_rate)\n user_mfccs = calculate_mfcc(user_pronunciation_audio, sample_rate)", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "mfcc_similarty_check", | |
"kind": 2, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "def mfcc_similarty_check(original: str, recorded: str):\n correct_pronunciation_audio, _ = load_and_resample_audio(original)\n user_pronunciation_audio, sample_rate = load_and_resample_audio(recorded)\n # Extract MFCCs from audio data\n correct_mfccs = calculate_mfcc(correct_pronunciation_audio, sample_rate)\n user_mfccs = calculate_mfcc(user_pronunciation_audio, sample_rate)\n distance = np.linalg.norm(correct_mfccs.flatten() - user_mfccs.flatten())\n # Calculate cosine similarity using MFCCs\n similarity_score = calculate_similarity(correct_mfccs, user_mfccs)\n accuracy_percentage = similarity_score * 100", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "model_id", | |
"kind": 5, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "model_id = \"facebook/w2v-bert-2.0\"\nfeature_extractor = AutoFeatureExtractor.from_pretrained(model_id)\nmodel = Wav2Vec2BertModel.from_pretrained(model_id)\ndef load_and_resample_audio(file_path, target_sample_rate=16000):\n audio_input, sample_rate = sf.read(file_path)\n if sample_rate != target_sample_rate:\n audio_input = librosa.resample(\n audio_input, orig_sr=sample_rate, target_sr=target_sample_rate\n )\n return audio_input, sample_rate", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "feature_extractor", | |
"kind": 5, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)\nmodel = Wav2Vec2BertModel.from_pretrained(model_id)\ndef load_and_resample_audio(file_path, target_sample_rate=16000):\n audio_input, sample_rate = sf.read(file_path)\n if sample_rate != target_sample_rate:\n audio_input = librosa.resample(\n audio_input, orig_sr=sample_rate, target_sr=target_sample_rate\n )\n return audio_input, sample_rate\ndef calculate_mfcc(audio_data, sample_rate):", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "model", | |
"kind": 5, | |
"importPath": "app.mfcc", | |
"description": "app.mfcc", | |
"peekOfCode": "model = Wav2Vec2BertModel.from_pretrained(model_id)\ndef load_and_resample_audio(file_path, target_sample_rate=16000):\n audio_input, sample_rate = sf.read(file_path)\n if sample_rate != target_sample_rate:\n audio_input = librosa.resample(\n audio_input, orig_sr=sample_rate, target_sr=target_sample_rate\n )\n return audio_input, sample_rate\ndef calculate_mfcc(audio_data, sample_rate):\n mfccs = librosa.feature.mfcc(y=audio_data, sr=sample_rate)", | |
"detail": "app.mfcc", | |
"documentation": {} | |
}, | |
{ | |
"label": "get_transcription", | |
"kind": 2, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "def get_transcription(file: str):\n result = pipe(file, generate_kwargs={\"language\": \"shona\"})\n return result[\"text\"]", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "device", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "device = \"cuda:0\" if torch.cuda.is_available() else \"cpu\"\ntorch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32\nmodel_id = \"openai/whisper-large-v3\"\nmodel = AutoModelForSpeechSeq2Seq.from_pretrained(\n model_id,\n torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True\n)\nmodel.to(device)\nprocessor = AutoProcessor.from_pretrained(model_id)\npipe = pipeline(", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "torch_dtype", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32\nmodel_id = \"openai/whisper-large-v3\"\nmodel = AutoModelForSpeechSeq2Seq.from_pretrained(\n model_id,\n torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True\n)\nmodel.to(device)\nprocessor = AutoProcessor.from_pretrained(model_id)\npipe = pipeline(\n \"automatic-speech-recognition\",", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "model_id", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "model_id = \"openai/whisper-large-v3\"\nmodel = AutoModelForSpeechSeq2Seq.from_pretrained(\n model_id,\n torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True\n)\nmodel.to(device)\nprocessor = AutoProcessor.from_pretrained(model_id)\npipe = pipeline(\n \"automatic-speech-recognition\",\n model=model,", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "model", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "model = AutoModelForSpeechSeq2Seq.from_pretrained(\n model_id,\n torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True\n)\nmodel.to(device)\nprocessor = AutoProcessor.from_pretrained(model_id)\npipe = pipeline(\n \"automatic-speech-recognition\",\n model=model,\n tokenizer=processor.tokenizer,", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "processor", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "processor = AutoProcessor.from_pretrained(model_id)\npipe = pipeline(\n \"automatic-speech-recognition\",\n model=model,\n tokenizer=processor.tokenizer,\n feature_extractor=processor.feature_extractor,\n max_new_tokens=128,\n chunk_length_s=30,\n batch_size=16,\n return_timestamps=True,", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "pipe", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "pipe = pipeline(\n \"automatic-speech-recognition\",\n model=model,\n tokenizer=processor.tokenizer,\n feature_extractor=processor.feature_extractor,\n max_new_tokens=128,\n chunk_length_s=30,\n batch_size=16,\n return_timestamps=True,\n torch_dtype=torch_dtype,", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "dataset", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "dataset = load_dataset(\n \"distil-whisper/librispeech_long\", \"clean\", split=\"validation\")\nsample = dataset[0][\"audio\"]\ndef get_transcription(file: str):\n result = pipe(file, generate_kwargs={\"language\": \"shona\"})\n return result[\"text\"]", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "sample", | |
"kind": 5, | |
"importPath": "app.transcriber", | |
"description": "app.transcriber", | |
"peekOfCode": "sample = dataset[0][\"audio\"]\ndef get_transcription(file: str):\n result = pipe(file, generate_kwargs={\"language\": \"shona\"})\n return result[\"text\"]", | |
"detail": "app.transcriber", | |
"documentation": {} | |
}, | |
{ | |
"label": "bin_dir", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "bin_dir = os.path.dirname(abs_file)\nbase = bin_dir[: -len(\"Scripts\") - 1] # strip away the bin part from the __file__, plus the path separator\n# prepend bin to PATH (this file is inside the bin directory)\nos.environ[\"PATH\"] = os.pathsep.join([bin_dir, *os.environ.get(\"PATH\", \"\").split(os.pathsep)])\nos.environ[\"VIRTUAL_ENV\"] = base # virtual env is right above bin directory\nos.environ[\"VIRTUAL_ENV_PROMPT\"] = \"\" or os.path.basename(base) # noqa: SIM222\n# add the virtual environments libraries to the host python import mechanism\nprev_length = len(sys.path)\nfor lib in \"..\\\\Lib\\\\site-packages\".split(os.pathsep):\n path = os.path.realpath(os.path.join(bin_dir, lib))", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "base", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "base = bin_dir[: -len(\"Scripts\") - 1] # strip away the bin part from the __file__, plus the path separator\n# prepend bin to PATH (this file is inside the bin directory)\nos.environ[\"PATH\"] = os.pathsep.join([bin_dir, *os.environ.get(\"PATH\", \"\").split(os.pathsep)])\nos.environ[\"VIRTUAL_ENV\"] = base # virtual env is right above bin directory\nos.environ[\"VIRTUAL_ENV_PROMPT\"] = \"\" or os.path.basename(base) # noqa: SIM222\n# add the virtual environments libraries to the host python import mechanism\nprev_length = len(sys.path)\nfor lib in \"..\\\\Lib\\\\site-packages\".split(os.pathsep):\n path = os.path.realpath(os.path.join(bin_dir, lib))\n site.addsitedir(path.decode(\"utf-8\") if \"\" else path)", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "os.environ[\"PATH\"]", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "os.environ[\"PATH\"] = os.pathsep.join([bin_dir, *os.environ.get(\"PATH\", \"\").split(os.pathsep)])\nos.environ[\"VIRTUAL_ENV\"] = base # virtual env is right above bin directory\nos.environ[\"VIRTUAL_ENV_PROMPT\"] = \"\" or os.path.basename(base) # noqa: SIM222\n# add the virtual environments libraries to the host python import mechanism\nprev_length = len(sys.path)\nfor lib in \"..\\\\Lib\\\\site-packages\".split(os.pathsep):\n path = os.path.realpath(os.path.join(bin_dir, lib))\n site.addsitedir(path.decode(\"utf-8\") if \"\" else path)\nsys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]\nsys.real_prefix = sys.prefix", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "os.environ[\"VIRTUAL_ENV\"]", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "os.environ[\"VIRTUAL_ENV\"] = base # virtual env is right above bin directory\nos.environ[\"VIRTUAL_ENV_PROMPT\"] = \"\" or os.path.basename(base) # noqa: SIM222\n# add the virtual environments libraries to the host python import mechanism\nprev_length = len(sys.path)\nfor lib in \"..\\\\Lib\\\\site-packages\".split(os.pathsep):\n path = os.path.realpath(os.path.join(bin_dir, lib))\n site.addsitedir(path.decode(\"utf-8\") if \"\" else path)\nsys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]\nsys.real_prefix = sys.prefix\nsys.prefix = base", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "os.environ[\"VIRTUAL_ENV_PROMPT\"]", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "os.environ[\"VIRTUAL_ENV_PROMPT\"] = \"\" or os.path.basename(base) # noqa: SIM222\n# add the virtual environments libraries to the host python import mechanism\nprev_length = len(sys.path)\nfor lib in \"..\\\\Lib\\\\site-packages\".split(os.pathsep):\n path = os.path.realpath(os.path.join(bin_dir, lib))\n site.addsitedir(path.decode(\"utf-8\") if \"\" else path)\nsys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]\nsys.real_prefix = sys.prefix\nsys.prefix = base", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "prev_length", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "prev_length = len(sys.path)\nfor lib in \"..\\\\Lib\\\\site-packages\".split(os.pathsep):\n path = os.path.realpath(os.path.join(bin_dir, lib))\n site.addsitedir(path.decode(\"utf-8\") if \"\" else path)\nsys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]\nsys.real_prefix = sys.prefix\nsys.prefix = base", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "sys.path[:]", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]\nsys.real_prefix = sys.prefix\nsys.prefix = base", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "sys.real_prefix", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "sys.real_prefix = sys.prefix\nsys.prefix = base", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
}, | |
{ | |
"label": "sys.prefix", | |
"kind": 5, | |
"importPath": "env.Scripts.activate_this", | |
"description": "env.Scripts.activate_this", | |
"peekOfCode": "sys.prefix = base", | |
"detail": "env.Scripts.activate_this", | |
"documentation": {} | |
} | |
] |