Unified acronym capitalization

See http://stackoverflow.com/a/27172000/52041
This commit is contained in:
Daniel Wolf 2016-11-16 11:49:25 +01:00
parent 3b599cc751
commit 8e1d1fbdd3
21 changed files with 69 additions and 69 deletions

View File

@ -111,7 +111,7 @@ set_target_properties(gtest_main PROPERTIES FOLDER lib)
include_directories(SYSTEM "lib/gsl/include")
# ... WebRTC
set(webRTCFiles
set(webRtcFiles
lib/webrtc-8d2248ff/webrtc/common_audio/signal_processing/cross_correlation.c
lib/webrtc-8d2248ff/webrtc/common_audio/signal_processing/division_operations.c
lib/webrtc-8d2248ff/webrtc/common_audio/signal_processing/downsample_fast.c
@ -130,16 +130,16 @@ set(webRTCFiles
lib/webrtc-8d2248ff/webrtc/common_audio/vad/vad_sp.c
lib/webrtc-8d2248ff/webrtc/common_audio/vad/webrtc_vad.c
)
add_library(webRTC ${webRTCFiles})
target_include_directories(webRTC SYSTEM PUBLIC "lib/webrtc-8d2248ff")
target_compile_options(webRTC PRIVATE ${disableWarningsFlags})
add_library(webRtc ${webRtcFiles})
target_include_directories(webRtc SYSTEM PUBLIC "lib/webrtc-8d2248ff")
target_compile_options(webRtc PRIVATE ${disableWarningsFlags})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(webRTC PRIVATE -pthread -lpthread)
target_compile_options(webRtc PRIVATE -pthread -lpthread)
endif()
if (NOT WIN32)
target_compile_definitions(webRTC PRIVATE WEBRTC_POSIX)
target_compile_definitions(webRtc PRIVATE WEBRTC_POSIX)
endif()
set_target_properties(webRTC PROPERTIES FOLDER lib)
set_target_properties(webRtc PROPERTIES FOLDER lib)
# ... whereami
add_library(whereami lib/whereami/src/whereami.c)
@ -236,8 +236,8 @@ add_library(rhubarb-audio
src/audio/AudioClip.h
src/audio/AudioSegment.cpp
src/audio/AudioSegment.h
src/audio/DCOffset.cpp
src/audio/DCOffset.h
src/audio/DcOffset.cpp
src/audio/DcOffset.h
src/audio/ioTools.h
src/audio/processing.cpp
src/audio/processing.h
@ -252,7 +252,7 @@ add_library(rhubarb-audio
)
target_include_directories(rhubarb-audio PUBLIC "src/audio")
target_link_libraries(rhubarb-audio
webRTC
webRtc
rhubarb-logging
rhubarb-time
rhubarb-tools

View File

@ -13,9 +13,9 @@ string ExportFormatConverter::getTypeName() {
EnumConverter<ExportFormat>::member_data ExportFormatConverter::getMemberData() {
return member_data{
{ ExportFormat::TSV, "TSV" },
{ ExportFormat::XML, "XML" },
{ ExportFormat::JSON, "JSON" }
{ ExportFormat::Tsv, "tsv" },
{ ExportFormat::Xml, "xml" },
{ ExportFormat::Json, "json" }
};
}

View File

@ -3,9 +3,9 @@
#include "EnumConverter.h"
enum class ExportFormat {
TSV,
XML,
JSON
Tsv,
Xml,
Json
};
class ExportFormatConverter : public EnumConverter<ExportFormat> {

View File

@ -1,27 +1,27 @@
#include "DCOffset.h"
#include "DcOffset.h"
#include <cmath>
using std::unique_ptr;
using std::make_unique;
DCOffset::DCOffset(unique_ptr<AudioClip> inputClip, float offset) :
DcOffset::DcOffset(unique_ptr<AudioClip> inputClip, float offset) :
inputClip(std::move(inputClip)),
offset(offset),
factor(1 / (1 + std::abs(offset)))
{}
unique_ptr<AudioClip> DCOffset::clone() const {
return make_unique<DCOffset>(*this);
unique_ptr<AudioClip> DcOffset::clone() const {
return make_unique<DcOffset>(*this);
}
SampleReader DCOffset::createUnsafeSampleReader() const {
SampleReader DcOffset::createUnsafeSampleReader() const {
return [read = inputClip->createSampleReader(), factor = factor, offset = offset](size_type index) {
float sample = read(index);
return sample * factor + offset;
};
}
float getDCOffset(const AudioClip& audioClip) {
float getDcOffset(const AudioClip& audioClip) {
int flatMeanSampleCount, fadingMeanSampleCount;
int sampleRate = audioClip.getSampleRate();
if (audioClip.size() > 4 * sampleRate) {
@ -49,16 +49,16 @@ float getDCOffset(const AudioClip& audioClip) {
return static_cast<float>(offset);
}
AudioEffect addDCOffset(float offset, float epsilon) {
AudioEffect addDcOffset(float offset, float epsilon) {
return [offset, epsilon](unique_ptr<AudioClip> inputClip) -> unique_ptr<AudioClip> {
if (std::abs(offset) < epsilon) return std::move(inputClip);
return make_unique<DCOffset>(std::move(inputClip), offset);
return make_unique<DcOffset>(std::move(inputClip), offset);
};
}
AudioEffect removeDCOffset(float epsilon) {
AudioEffect removeDcOffset(float epsilon) {
return [epsilon](unique_ptr<AudioClip> inputClip) {
float offset = getDCOffset(*inputClip);
return std::move(inputClip) | addDCOffset(-offset, epsilon);
float offset = getDcOffset(*inputClip);
return std::move(inputClip) | addDcOffset(-offset, epsilon);
};
}

View File

@ -4,9 +4,9 @@
// Applies a constant DC offset to an audio clip and reduces its amplitude
// to prevent clipping
class DCOffset : public AudioClip {
class DcOffset : public AudioClip {
public:
DCOffset(std::unique_ptr<AudioClip> inputClip, float offset);
DcOffset(std::unique_ptr<AudioClip> inputClip, float offset);
std::unique_ptr<AudioClip> clone() const override;
int getSampleRate() const override;
size_type size() const override;
@ -18,15 +18,15 @@ private:
float factor;
};
inline int DCOffset::getSampleRate() const {
inline int DcOffset::getSampleRate() const {
return inputClip->getSampleRate();
}
inline AudioClip::size_type DCOffset::size() const {
inline AudioClip::size_type DcOffset::size() const {
return inputClip->size();
}
float getDCOffset(const AudioClip& audioClip);
float getDcOffset(const AudioClip& audioClip);
AudioEffect addDCOffset(float offset, float epsilon = 1.0f / 15000);
AudioEffect removeDCOffset(float epsilon = 1.0f / 15000);
AudioEffect addDcOffset(float offset, float epsilon = 1.0f / 15000);
AudioEffect removeDcOffset(float epsilon = 1.0f / 15000);

View File

@ -26,7 +26,7 @@ int roundToEven(int i) {
}
namespace Codec {
constexpr int PCM = 0x01;
constexpr int Pcm = 0x01;
constexpr int Float = 0x03;
};
@ -103,7 +103,7 @@ WaveFileReader::WaveFileReader(path filePath) :
// Determine sample format
int bytesPerSample;
switch (codec) {
case Codec::PCM:
case Codec::Pcm:
// Determine sample size.
// According to the WAVE standard, sample sizes that are not multiples of 8 bits
// (e.g. 12 bits) can be treated like the next-larger byte size.
@ -135,7 +135,7 @@ WaveFileReader::WaveFileReader(path filePath) :
default:
throw runtime_error(format(
"Unsupported audio codec: '{}'. Only uncompressed codecs ('{}' and '{}') are supported.",
codecToString(codec), codecToString(Codec::PCM), codecToString(Codec::Float)));
codecToString(codec), codecToString(Codec::Pcm), codecToString(Codec::Float)));
}
formatInfo.bytesPerFrame = bytesPerSample * formatInfo.channelCount;
break;

View File

@ -1,5 +1,5 @@
#include "voiceActivityDetection.h"
#include "DCOffset.h"
#include "DcOffset.h"
#include "SampleRateConverter.h"
#include "logging.h"
#include "pairs.h"
@ -68,7 +68,7 @@ BoundedTimeline<void> webRtcDetectVoiceActivity(const AudioClip& audioClip, Prog
BoundedTimeline<void> detectVoiceActivity(const AudioClip& inputAudioClip, int maxThreadCount, ProgressSink& progressSink) {
// Prepare audio for VAD
const unique_ptr<AudioClip> audioClip = inputAudioClip.clone() | resample(16000) | removeDCOffset();
const unique_ptr<AudioClip> audioClip = inputAudioClip.clone() | resample(16000) | removeDcOffset();
BoundedTimeline<void> activity(audioClip->getTruncatedRange());
std::mutex activityMutex;

View File

@ -3,7 +3,7 @@
using std::string;
string escapeJSONString(const string& s) {
string escapeJsonString(const string& s) {
string result;
for (char c : s) {
switch (c) {
@ -25,12 +25,12 @@ string escapeJSONString(const string& s) {
return result;
}
void JSONExporter::exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) {
void JsonExporter::exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) {
// Export as JSON.
// I'm not using a library because the code is short enough without one and it lets me control the formatting.
outputStream << "{\n";
outputStream << " \"metadata\": {\n";
outputStream << " \"soundFile\": \"" << escapeJSONString(inputFilePath.string()) << "\",\n";
outputStream << " \"soundFile\": \"" << escapeJsonString(inputFilePath.string()) << "\",\n";
outputStream << " \"duration\": " << formatDuration(shapes.getRange().getDuration()) << "\n";
outputStream << " },\n";
outputStream << " \"mouthCues\": [\n";

View File

@ -2,7 +2,7 @@
#include "Exporter.h"
class JSONExporter : public Exporter {
class JsonExporter : public Exporter {
public:
void exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) override;
};

View File

@ -1,6 +1,6 @@
#include "TsvExporter.h"
void TSVExporter::exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) {
void TsvExporter::exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) {
UNUSED(inputFilePath);
// Output shapes with start times

View File

@ -2,7 +2,7 @@
#include "Exporter.h"
class TSVExporter : public Exporter {
class TsvExporter : public Exporter {
public:
void exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) override;
};

View File

@ -6,7 +6,7 @@
using std::string;
using boost::property_tree::ptree;
void XMLExporter::exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) {
void XmlExporter::exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) {
ptree tree;
// Add metadata

View File

@ -2,7 +2,7 @@
#include "Exporter.h"
class XMLExporter : public Exporter {
class XmlExporter : public Exporter {
public:
void exportShapes(const boost::filesystem::path& inputFilePath, const ContinuousTimeline<Shape>& shapes, std::ostream& outputStream) override;
};

View File

@ -68,12 +68,12 @@ void addFileSink(path path, logging::Level minLevel) {
unique_ptr<Exporter> createExporter(ExportFormat exportFormat) {
switch (exportFormat) {
case ExportFormat::TSV:
return make_unique<TSVExporter>();
case ExportFormat::XML:
return make_unique<XMLExporter>();
case ExportFormat::JSON:
return make_unique<JSONExporter>();
case ExportFormat::Tsv:
return make_unique<TsvExporter>();
case ExportFormat::Xml:
return make_unique<XmlExporter>();
case ExportFormat::Json:
return make_unique<JsonExporter>();
default:
throw std::runtime_error("Unknown export format.");
}
@ -98,7 +98,7 @@ int main(int argc, char *argv[]) {
tclap::ValueArg<string> dialogFile("d", "dialogFile", "A file containing the text of the dialog.", false, string(), "string", cmd);
auto exportFormats = vector<ExportFormat>(ExportFormatConverter::get().getValues());
tclap::ValuesConstraint<ExportFormat> exportFormatConstraint(exportFormats);
tclap::ValueArg<ExportFormat> exportFormat("f", "exportFormat", "The export format.", false, ExportFormat::TSV, &exportFormatConstraint, cmd);
tclap::ValueArg<ExportFormat> exportFormat("f", "exportFormat", "The export format.", false, ExportFormat::Tsv, &exportFormatConstraint, cmd);
tclap::UnlabeledValueArg<string> inputFileName("inputFile", "The input file. Must be a sound file in WAVE format.", true, "", "string", cmd);
try {
@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
// Animate the recording
animation = animateWaveFile(
inputFileName.getValue(),
dialogFile.isSet() ? readUTF8File(path(dialogFile.getValue())) : boost::optional<u32string>(),
dialogFile.isSet() ? readUtf8File(path(dialogFile.getValue())) : boost::optional<u32string>(),
maxThreadCount.getValue(),
progressBar);
}

View File

@ -8,7 +8,7 @@
#include <regex>
#include <gsl_util.h>
#include <logging.h>
#include "DCOffset.h"
#include "DcOffset.h"
#include "Timeline.h"
#include "voiceActivityDetection.h"
#include "AudioSegment.h"
@ -427,7 +427,7 @@ BoundedTimeline<Phone> recognizePhones(
ProgressSink& dialogProgressSink = totalProgressMerger.addSink(15);
// Make sure audio stream has no DC offset
const unique_ptr<AudioClip> audioClip = inputAudioClip.clone() | removeDCOffset();
const unique_ptr<AudioClip> audioClip = inputAudioClip.clone() | removeDcOffset();
// Split audio into utterances
BoundedTimeline<void> utterances;

View File

@ -74,7 +74,7 @@ optional<string> findSimilarDictionaryWord(const string& word, function<bool(con
}
vector<string> tokenizeText(const u32string& text, function<bool(const string&)> dictionaryContains) {
vector<string> words = tokenizeViaFlite(toASCII(text));
vector<string> words = tokenizeViaFlite(toAscii(text));
// Join words separated by apostophes
for (int i = words.size() - 1; i > 0; --i) {

View File

@ -91,7 +91,7 @@ wstring latin1ToWide(const string& s) {
return result;
}
optional<char> toASCII(char32_t ch) {
optional<char> toAscii(char32_t ch) {
switch (ch) {
#include "asciiCases.cpp"
default:
@ -99,10 +99,10 @@ optional<char> toASCII(char32_t ch) {
}
}
string toASCII(const u32string& s) {
string toAscii(const u32string& s) {
string result;
for (char32_t ch : s) {
optional<char> ascii = toASCII(ch);
optional<char> ascii = toAscii(ch);
if (ascii) result.append(1, *ascii);
}
return result;

View File

@ -12,9 +12,9 @@ std::vector<std::string> wrapString(const std::string& s, int lineLength, int ha
std::wstring latin1ToWide(const std::string& s);
boost::optional<char> toASCII(char32_t ch);
boost::optional<char> toAscii(char32_t ch);
std::string toASCII(const std::u32string& s);
std::string toAscii(const std::u32string& s);
std::u32string utf8ToUtf32(const std::string& s);

View File

@ -8,7 +8,7 @@ using std::string;
using std::u32string;
using boost::filesystem::path;
u32string readUTF8File(path filePath) {
u32string readUtf8File(path filePath) {
if (!exists(filePath)) {
throw std::invalid_argument(fmt::format("File {} does not exist.", filePath));
}

View File

@ -2,4 +2,4 @@
#include <boost/filesystem/path.hpp>
std::u32string readUTF8File(boost::filesystem::path filePath);
std::u32string readUtf8File(boost::filesystem::path filePath);

View File

@ -81,11 +81,11 @@ TEST(latin1ToWide, basic) {
EXPECT_EQ(pangramWide, latin1ToWide(pangramLatin1));
}
// toASCII
// toAscii
TEST(toASCII, string) {
TEST(toAscii, string) {
EXPECT_EQ(
"A naive man called was having pina colada and creme brulee.",
toASCII(U"A naïve man called 晨 was having piña colada and crème brûlée."));
EXPECT_EQ(string(""), toASCII(U""));
toAscii(U"A naïve man called 晨 was having piña colada and crème brûlée."));
EXPECT_EQ(string(""), toAscii(U""));
}