Snippets Collections
# Add the tables to the DocumentStore

import json
from haystack import Document
import pandas as pd

def read_tables(filename):
    processed_tables = []
    with open(filename) as tables:
        tables = json.load(tables)
        for key, table in tables.items():
            current_columns = table["header"]
            current_rows = table["data"]
            current_df = pd.DataFrame(columns=current_columns, data=current_rows)
            document = Document(content=current_df, content_type="table", id=key)

    return processed_tables

tables = read_tables(f"{doc_dir}/tables.json")
document_store.write_documents(tables, index=document_index)

# Showing content field and meta field of one of the Documents of content_type 'table'
from IPython.display import YouTubeVideo

YOUTUBE_ID = 'xxxxxxxxxxxx'

!rm -rf *.wav
!youtube-dl --extract-audio --audio-format wav --output "downloaded.%(ext)s"\?v\={YOUTUBE_ID}
!ffmpeg -loglevel panic -y -i downloaded.wav -acodec pcm_s16le -ac 1 -ar 16000 {project_name}/test.wav
find . -name '*.wav' -exec ffmpeg -i '{}' -i cars-passing-close-by-wet-road-23734.mp3 -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" '{}.bkgnoise.wav' \;
find . -name '*.wav' -exec ffmpeg -i '{}' -filter:a "highpass=f=1200" '{}.phone.wav' \;
find . -name '*.wav' -exec ffmpeg -i '{}' -ar 16000 -ac 1 '{}.mono.wav' \;
//MARK: - Document Picker

// From your project's capabilities, enable both the iCloud and the Key-Sharing.

@IBAction func pickDocumentPressed(_ sender: Any) {

extension OffersReceivedViewController : UIDocumentPickerDelegate,UINavigationControllerDelegate {
    func presentDocumentPicker() {
        let sTypes = getSupportedTypes()
        let documentPickerController = UIDocumentPickerViewController(
            forOpeningContentTypes: sTypes)
        documentPickerController.delegate = self
        documentPickerController.allowsMultipleSelection = false
        self.present(documentPickerController, animated: true) {
    public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        guard let myURL = urls.first else {
        print("import result : \(myURL)")
        print("get Image Url")
        fileUrl = myURL
    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
        print("view was cancelled")
        dismiss(animated: true, completion: nil)
    func getSupportedTypes() -> [UTType] {
        let supportedTypes : [UTType] = [UTType.utf8TabSeparatedText, UTType.rtf,    UTType.pdf, UTType.webArchive, UTType.image, UTType.jpeg,    UTType.tiff, UTType.gif, UTType.png, UTType.bmp, UTType.ico,    UTType.rawImage, UTType.svg, UTType.livePhoto,,,, UTType.quickTimeMovie, UTType.mpeg,    UTType.mpeg2Video, UTType.mpeg2TransportStream, UTType.mp3,    UTType.mpeg4Movie, UTType.mpeg4Audio, UTType.avi, UTType.aiff,    UTType.wav, UTType.midi, UTType.archive, UTType.gzip, UTType.bz2,, UTType.appleArchive, UTType.spreadsheet, UTType.epub]
        return supportedTypes

Mon Jun 27 2022 10:53:43 GMT+0000 (UTC)

#ios #swift #file #pdf #doc #document #picker #mp3 #mp4 #video #audio

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension