Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
Beta v0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodz committed Mar 26, 2021
1 parent c12d9ad commit 6bec10d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<a href="#">
<img src="docs/banner.png">
</a>
<h3 align="center">AiCleaner<br>
Audio denoising real-time powered by artificial intelligence (Alpha)</h3>
<h3 align="center">VoiceCleaner<br>
Audio denoising real-time powered by artificial intelligence (Beta)</h3>
</p>

>Name of the project may change on future.
>Name of the project may change on future.
>Old-name: aicleaner
<hr style="height:2px;border-width:0;color:gray;background-color:gray">
<!-- TABLE OF CONTENTS -->
Expand Down
Binary file modified docs/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 26 additions & 21 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
sample_rate_output = 8000 # default 8000 due restrictions, can't be more by 2021-03-02
record_seconds = 1.2 # default 1.1 due some restrictions
INITIAL_DELAY_SECONDS = 0.5 # initial delay in seconds to create threads
DELAY_IDLE=0.01 # seconds to sleep until check again the queue
DELAY_IDLE = 0.01 # seconds to sleep until check again the queue
console.print("[GLOBAL CONFIGS] Finish loading variables and constants.",
style="bold green")

Expand All @@ -61,7 +61,7 @@ def hello():
|Mantainer: Pablo Diaz (github.com/zurmad) |
|Github: https://github.com/DZDL/aicleaner |
|License: MIT |
|Version: Alpha v0.1 [2020-03-13] |
|Version: Alpha v0.2 [2020-03-26] |
|Operative System detected: {}
|Branch: MultiProcessing - 4 main Process (Server, Record, Process, Play) |
|---------------------------------------------------------------------------------------------|""".format(sys.platform), style="bold yellow")
Expand Down Expand Up @@ -159,7 +159,8 @@ def record_only_Process(queue_data_recorded,
numframes = int(sample_rate_input*record_seconds)

default_mic = sc.default_microphone()
recorder = default_mic.recorder(sample_rate_input, channels=channels, blocksize=256)
recorder = default_mic.recorder(
sample_rate_input, channels=channels, blocksize=256)

with recorder as r:
while True:
Expand Down Expand Up @@ -200,7 +201,7 @@ def process_only_Process(queue_data_recorded,
# release the first queued but get the value
mydata = queue_data_recorded.get()
console.print('{} PROCESS: {}'.format(process_name,
str(number)),style="bold green")
str(number)), style="bold green")

# With data as numpy array
mydata_predicted = executeprediction(aimodel='speechenhancement',
Expand All @@ -212,7 +213,7 @@ def process_only_Process(queue_data_recorded,
queue_data_to_play_index.put(number)
queue_data_to_play.put(mydata_predicted)
else:
time.sleep(DELAY_IDLE) # to don't stress cpu
time.sleep(DELAY_IDLE) # to don't stress cpu


def play_only_Process(queue_data_to_play,
Expand All @@ -230,7 +231,8 @@ def play_only_Process(queue_data_to_play,
time.sleep(INITIAL_DELAY_SECONDS*2)

default_speaker = sc.default_speaker()
default_speaker_player = default_speaker.player(sample_rate_output, channels=channels, blocksize=256)
default_speaker_player = default_speaker.player(
sample_rate_output, channels=channels, blocksize=256)

with default_speaker_player as p:
while True:
Expand All @@ -245,7 +247,7 @@ def play_only_Process(queue_data_to_play,

p.play(mydata_predicted/numpy.max(mydata_predicted))
else:
time.sleep(DELAY_IDLE) # to don't stress cpu
time.sleep(DELAY_IDLE) # to don't stress cpu


def power_on_tensorflow_serving_Process():
Expand All @@ -258,22 +260,22 @@ def power_on_tensorflow_serving_Process():
api_port = 8501
model_name = 'model_unet'
model_base_path = os.path.dirname(os.path.abspath('main.py'))
model_relative_path=model_base_path+'/aimodels/speechenhancement/serving/'
model_relative_path = model_base_path+'/aimodels/speechenhancement/serving/'

command = 'tensorflow_model_server --rest_api_port={} --model_name={} --model_base_path="{}"'.format(api_port,
model_name,
model_relative_path)
model_name,
model_relative_path)

process_name = current_process().name

console.print('{} TENSORFLOW SERVER TURNING ON...'.format(process_name),
style="bold green")
style="bold green")
# Turn on
print(command)
os.popen(command)

console.print('{} TENSORFLOW SERVER READY.'.format(process_name),
style="bold green")
style="bold green")


"""
Expand All @@ -297,26 +299,29 @@ def power_on_tensorflow_serving_Process():
time.sleep(INITIAL_DELAY_SECONDS) # drivers slow start needed

# Turn on server of tensorflow serving
P0_SERVER_PROCESS=Process(target=power_on_tensorflow_serving_Process,name='[P0][SERVER]')
P0_SERVER_PROCESS = Process(target=power_on_tensorflow_serving_Process,
name='[P0][SERVER]')
P0_SERVER_PROCESS.start()
P0_SERVER_PROCESS.join()

time.sleep(INITIAL_DELAY_SECONDS) # drivers slow start needed

# Record voice continously
P1_RECORDER_PROCESS = Process(target=record_only_Process,
args=((queue_data_recorded),(queue_data_recorded_index)),
name='[P1][RECORDER]')
args=((queue_data_recorded),
(queue_data_recorded_index)),
name='[P1][RECORDER]')
# Process as queued
P2_PROCESSMODEL_PROCESS = Process(target=process_only_Process,
args=((queue_data_recorded),
(queue_data_recorded_index),
P2_PROCESSMODEL_PROCESS = Process(target=process_only_Process,
args=((queue_data_recorded),
(queue_data_recorded_index),
(queue_data_to_play),
(queue_data_to_play_index)),
name='[P2][DIGESTOR]')
name='[P2][DIGESTOR]')
# Play as finished processed
P3_PLAYER_PROCESS = Process(target=play_only_Process,
args=((queue_data_to_play),(queue_data_to_play_index)),
P3_PLAYER_PROCESS = Process(target=play_only_Process,
args=((queue_data_to_play),
(queue_data_to_play_index)),
name='[P3][PLAYER]')

# Charge and join threads
Expand Down

0 comments on commit 6bec10d

Please sign in to comment.