knn-voice-conversion / knnvc_utils.py
wetdog's picture
Inital demo
c52280c
raw
history blame
546 Bytes
import numpy as np
def generate_matrix_from_index(A, len=25):
matrix = np.zeros(len, dtype=float)
matrix[A] = 1
return matrix
def retrieve_index_from_matrix(matrix):
A = np.where(matrix == 1)[0]
return A
if __name__ == '__main__':
# Generating a matrix from index A
A = 6
matrix = generate_matrix_from_index(A)
print("Generated Matrix:")
print(matrix)
# Retrieving index A from the matrix
retrieved_A = retrieve_index_from_matrix(matrix)
print("Retrieved Index A:")
print(retrieved_A)