Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
144 additions
and
69 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .minutes import Minutes # noqa | ||
from .speaker import Speaker # noqa | ||
from .conversation import Conversation # noqa | ||
from minutes.minutes import Minutes # noqa | ||
from minutes.speaker import Speaker # noqa | ||
from minutes.conversation import Phrase, Conversation # noqa |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
from minutes.audio import Audio | ||
|
||
|
||
class Conversation: | ||
class Phrase: | ||
def __init__(self, observation, speaker): | ||
"""A phrase in a conversation, characterized by an audio segment | ||
and a speaker. | ||
def __init__(self, audio_loc, speakers): | ||
Arguments: | ||
observation {np.array} -- 1 dimensional audio sample. | ||
speaker {Speaker} -- The inferred speaker for the audio segment. | ||
""" | ||
self.observation = observation | ||
self.speaker = speaker | ||
|
||
|
||
class Conversation(Audio): | ||
|
||
def __init__(self, audio_loc, model): | ||
"""Create a new conversation from audio sample. | ||
Arguments: | ||
audio_loc {str} -- The absolute location of an audio conversation | ||
sample. | ||
speakers {List[Speaker]} -- A list of speakers included in this | ||
model {Minutes} -- A model trained on speakers within this | ||
conversation. | ||
""" | ||
self.speakers = speakers | ||
self.audio = Audio(audio_loc) | ||
|
||
def get_observations(self, ms_per_observation, verbose=False): | ||
"""Converts the conversation audio sample into an n x d matrix of | ||
observations. | ||
self.model = model | ||
super().__init__(audio_loc) | ||
|
||
Keyword Arguments: | ||
verbose {bool} -- (default: {False}) | ||
ms_per_observation {int} -- (default: {False}) | ||
Returns: | ||
np.array -- An n x d matrix of observations. | ||
""" | ||
return self.audio.get_spectrograms(ms_per_observation, verbose) | ||
# Predict against the conversation spectrograms. | ||
raw, X_hat = self.get_observations(**model.preprocessing_params) | ||
y_hat = model.predict(X_hat) | ||
|
||
# Convert to a list of phrases. | ||
self.phrases = [Phrase(o, speaker) for o, speaker in zip(raw, y_hat)] |
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
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
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
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
Binary file not shown.
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
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