Skip to content

Commit

Permalink
docs, energy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
drfeinberg committed Jan 25, 2023
1 parent 2edab2a commit 7414903
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Voicelab/toolkits/Voicelab/MeasureEnergyNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from Voicelab.toolkits.Voicelab.VoicelabNode import VoicelabNode





class MeasureEnergyNode(VoicelabNode):
"""Measure Energy like in VoiceSauce
Expand Down Expand Up @@ -196,13 +199,16 @@ def get_raw_pitch(self, audio_file_path: str) -> tuple[pd.DataFrame, pd.DataFram
pitch_floor=40,
pitch_ceiling=500,
)
pitch_tier: parselmouth.Data = call(pitch, "Down to PitchTier")
# get the directory where this file is located
dir_path = os.path.dirname(os.path.realpath(__file__))
call(pitch_tier, "Write to headerless spreadsheet file", f"{dir_path}/parselmouth_cc.txt")
df: pd.DataFrame = pd.read_csv(f'{dir_path}/parselmouth_cc.txt', sep='\t', header=None)
df.columns = ['Time', 'Frequency']
return df.Time.values, df.Frequency.values
#pitch_tier: parselmouth.Data = call(pitch, "Down to PitchTier")

df = pd.DataFrame()
df['Time'] = pitch.xs()
df['Frequency'] = [pitch.get_value_at_time(value) for value in pitch.xs()]

#call(pitch_tier, "Write to headerless spreadsheet file", f"{dir_path}/parselmouth_cc.txt")
#df: pd.DataFrame = pd.read_csv(f'{dir_path}/parselmouth_cc.txt', sep='\t', header=None)
#df.columns = ['Time', 'Frequency']
return df.Time, df.Frequency


def refine_pitch_voice_sauce(self, times: pd.DataFrame, frequencies: pd.DataFrame) -> np.array:
Expand Down Expand Up @@ -288,3 +294,4 @@ def round_half_away_from_zero(self, x) -> np.int_:
q: np.int_ = np.int_(np.sign(x) * np.floor(np.abs(x) + 0.5))

return q

0 comments on commit 7414903

Please sign in to comment.